From 29a04c0a3c073a7b853deec5fe6d6bafb4df90a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Jun 2024 07:09:39 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 4 +- CONTRIBUTORS | 3 +- README.md | 5 + benchmark/benchmark.set.js | 38 + dist/index.js | 112 +- dist/index.js.map | 8 +- docs/types/index.d.ts | 114 +- docs/types/test.ts | 2 + examples/index.js | 6 + lib/get_elements.js | 1 - lib/set.js | 5 + lib/set_elements.js | 97 ++ lib/set_slice.js | 3 +- lib/validator.js | 38 +- package.json | 3 + test/test.set.integer_array.js | 1864 ++++++++++++++++++++++++++++++++ test/test.set.integers.js | 70 ++ test/test.set.invalid.js | 131 +++ 18 files changed, 2325 insertions(+), 179 deletions(-) create mode 100644 lib/set_elements.js create mode 100644 test/test.set.integer_array.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f4a03b..b3c4239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,13 @@
-## Unreleased (2024-06-05) +## Unreleased (2024-06-18)
### Features +- [`b079d65`](https://github.com/stdlib-js/stdlib/commit/b079d653226019925581555fdaf9aa927ec69c0e) - add support for integer array indexing assignment - [`96e896a`](https://github.com/stdlib-js/stdlib/commit/96e896a39be08912b2e06dfb6b671ec13d042412) - add support for boolean array indices
@@ -22,6 +23,7 @@
+- [`b079d65`](https://github.com/stdlib-js/stdlib/commit/b079d653226019925581555fdaf9aa927ec69c0e) - **feat:** add support for integer array indexing assignment _(by Athan Reines)_ - [`96e896a`](https://github.com/stdlib-js/stdlib/commit/96e896a39be08912b2e06dfb6b671ec13d042412) - **feat:** add support for boolean array indices _(by Athan Reines)_ - [`75d4f83`](https://github.com/stdlib-js/stdlib/commit/75d4f83cb85610d23a04dc21a03f8075f6d3665f) - **refactor:** update require and include paths _(by Athan Reines)_ diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a44d7ac..7ec15a7 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -63,6 +63,7 @@ Pushpendra Chandravanshi Raunak Kumar Gupta Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Ricky Reusser +Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Robert Gislason Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Rutam <138517416+performant23@users.noreply.github.com> @@ -75,7 +76,7 @@ Shraddheya Shendre Shubh Mehta <93862397+Shubh942@users.noreply.github.com> Shubham Mishra Sivam Das <100067002+Sivam2313@users.noreply.github.com> -Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com> +Snehil Shah Soumajit Chatterjee <121816890+soumajit23@users.noreply.github.com> Spandan Barve Stephannie Jiménez Gacha diff --git a/README.md b/README.md index a552ff0..4e50509 100644 --- a/README.md +++ b/README.md @@ -489,6 +489,7 @@ im = imag( v ); ```javascript var Uint8Array = require( '@stdlib/array-uint8' ); var Int32Array = require( '@stdlib/array-int32' ); +var BooleanArray = require( '@stdlib/array-bool' ); var array2fancy = require( '@stdlib/array-to-fancy' ); var x = [ 1, 2, 3, 4, 5, 6 ]; @@ -525,6 +526,10 @@ i = idx( [ true, false, false, true, true, true ] ); // boolean array z = y[ i ]; // returns [ 1, -9, -8, 6 ] +i = idx( new BooleanArray( [ true, false, false, true, true, true ] ) ); // boolean array +z = y[ i ]; +// returns [ 1, -9, -8, 6 ] + i = idx( new Uint8Array( [ 0, 0, 1, 0, 0, 1 ] ) ); // mask array z = y[ i ]; // returns [ 1, 2, -9, -8 ] diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js index 99061f8..e03cca0 100644 --- a/benchmark/benchmark.set.js +++ b/benchmark/benchmark.set.js @@ -155,3 +155,41 @@ bench( pkg+'::set,subsequence:len=1', opts, function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); }); + +bench( pkg+'::set,integer_array:len=1', opts, function benchmark( b ) { + var values; + var base; + var opts; + var idx; + var x; + var v; + var i; + + base = zeroTo( 100, 'generic' ); + x = array2fancy( base ); + + opts = { + 'persist': true + }; + values = [ + array2fancy.idx( [ 0 ], opts ), + array2fancy.idx( [ 1 ], opts ), + array2fancy.idx( [ 2 ], opts ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = values[ i%values.length ]; + x[ idx ] = i * 2; + v = base[ i%3 ]; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/dist/index.js b/dist/index.js index 19e2694..0d40f73 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,57 +1,59 @@ -"use strict";var u=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var S=u(function(At,b){ -var Ar=require('@stdlib/array-base-assert-is-complex-floating-point-data-type/dist'),xr=require('@stdlib/assert-is-number/dist').isPrimitive;function Tr(r){return xr(r)?[r,0]:r}function Rr(r){return Ar(r)?Tr:null}b.exports=Rr -});var A=u(function(xt,I){ -function Dr(r,i){return a;function a(t){return r(t,i)}}I.exports=Dr -});var T=u(function(Tt,x){ -var kr=require('@stdlib/proxy-ctor/dist'),_r=typeof kr=="function";x.exports=_r -});var D=u(function(Rt,R){ -var Pr=require('@stdlib/array-index/dist');function Nr(){return{cache:Pr,strict:!1}}R.exports=Nr -});var P=u(function(Dt,_){ -var Vr=require('@stdlib/assert-is-plain-object/dist'),k=require('@stdlib/assert-has-own-property/dist'),Ur=require('@stdlib/assert-is-boolean/dist').isPrimitive,Cr=require('@stdlib/assert-is-method-in/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function Or(r,i){return Vr(i)?k(i,"strict")&&(r.strict=i.strict,!Ur(r.strict))?new TypeError(y('1rX2o',"strict",r.strict)):k(i,"cache")&&(r.cache=i.cache,!Cr(r.cache,"get"))?new TypeError(y('1rXFb',"cache","get",r.cache)):null:new TypeError(y('1rX2V',i));}_.exports=Or -});var C=u(function(kt,U){ -var l=require('@stdlib/assert-is-number/dist').isPrimitive,Gr=require('@stdlib/assert-is-integer/dist').isPrimitive,f=require('@stdlib/assert-is-complex-like/dist'),Fr=require('@stdlib/array-base-assert-is-real-floating-point-data-type/dist'),Lr=require('@stdlib/array-base-assert-is-unsigned-integer-data-type/dist'),jr=require('@stdlib/array-base-assert-is-signed-integer-data-type/dist'),N=require('@stdlib/array-base-assert-is-safe-data-type-cast/dist'),V=require('@stdlib/array-min-dtype/dist'),Br=require('@stdlib/array-base-min-signed-integer-dtype/dist'),d=require('@stdlib/complex-dtype/dist'),c=require('@stdlib/error-tools-fmtprodmsg/dist');function Mr(){return null}function Wr(r,i){return l(r)?null:f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function zr(r,i){return l(r)||f(r)?null:new TypeError(c('1rXEw',typeof r,i));}function Qr(r,i){var a;return l(r)?Gr(r)?(a=Br(r),N(a,i)?null:new TypeError(c('1rXEw',a,i))):new TypeError(c('1rXEw',V(r),i)):f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function Xr(r,i){var a;return l(r)?(a=V(r),N(a,i)?null:new TypeError(c('1rXEw',a,i))):f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function Yr(r){return r==="generic"||r===""?Mr:Fr(r)?Wr:Lr(r)?Xr:jr(r)?Qr:zr}U.exports=Yr -});var G=u(function(_t,O){ -function $r(r,i){return a;function a(t,n){var s,e;switch(e=n,e.length){case 0:s=new t;break;case 1:s=new t(e[0]);break;case 2:s=new t(e[0],e[1]);break;case 3:s=new t(e[0],e[1],e[2]);break;case 4:s=new t(e[0],e[1],e[2],e[3]);break;case 5:s=new t(e[0],e[1],e[2],e[3],e[4]);break;case 6:s=new t(e[0],e[1],e[2],e[3],e[4],e[5]);break;case 7:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6]);break;case 8:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]);break;case 9:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]);break;case 10:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9]);break;default:s=t.apply(null,e)}return r(s,i)}}O.exports=$r -});var L=u(function(Pt,F){ -var Hr=/^-?[0-9]+$/;F.exports=Hr -});var q=u(function(Nt,j){ -var Jr=require('@stdlib/assert-is-string/dist').isPrimitive,Kr=L();function Zr(r){return Jr(r)&&Kr.test(r)}j.exports=Zr -});var M=u(function(Vt,B){ -var re=/\s*ArrayIndex<[^>]+>\s*/;B.exports=re -});var z=u(function(Ut,W){ -var ee=require('@stdlib/assert-is-string/dist').isPrimitive,te=M();function ie(r){return ee(r)&&te.test(r)}W.exports=ie -});var X=u(function(Ct,Q){ -var ae=require('@stdlib/string-base-trim/dist'),ne=require('@stdlib/error-tools-fmtprodmsg/dist');function se(r){return r.substring(11,r.length-1)}function ue(r,i){var a=i.get(se(ae(r)));if(a===null)throw new Error(ne('1rXFa',r));return a}Q.exports=ue -});var $=u(function(Ot,Y){ -var oe=require('@stdlib/array-take/dist'),ce=require('@stdlib/array-mskfilter/dist'),ve=require('@stdlib/array-mskreject/dist'),le=require('@stdlib/error-tools-fmtprodmsg/dist'),fe=X();function pe(r,i,a){var t=fe(i,a.cache);if(t.type==="int")return a.postGetArray(oe(r,t.data));if(t.type==="bool")return a.postGetArray(ce(r,t.data));if(t.type==="mask")return a.postGetArray(ve(r,t.data));throw new Error(le('1rXFZ',t.type))}Y.exports=pe -});var g=u(function(Gt,H){ -var ye=require('@stdlib/ndarray-base-normalize-index/dist'),de=require('@stdlib/error-tools-fmtprodmsg/dist');function qe(r,i,a){var t,n;if(t=parseInt(r,10),n=ye(t,i-1),n===-1){if(a)throw new RangeError(de('1rXFY'));return t}return n}H.exports=qe -});var K=u(function(Ft,J){ -var ge=g();function me(r,i,a){return a.getter(r,ge(i,r.length,a.strict))}J.exports=me -});var rr=u(function(Lt,Z){ -var he=require('@stdlib/assert-is-function/dist');function we(r,i,a,t){var n=r[i];if(he(n))return n===r.constructor?t.ctor:s;return n;function s(){var e,o;for(e=[],o=0;o1&&(s=wr(n,arguments[1]),s))throw s;return e=ot(t),o=e.dtype||"",v={ref:t,dtype:o,getter:e.accessors[0],setter:e.accessors[1],preSetElement:lt(o),postGetArray:ft(a,n),cache:n.cache,strict:n.strict,validator:dt(o),array2fancy:a,ctor:new hr(t.constructor||Array,{construct:qt(a,n)})},new hr(t,{get:gt(v),set:mt(v)})}return console.warn("WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available."),t}}Er.exports=ht -});var Sr=u(function(Jt,br){ -var wt=w(),Et=wt();br.exports=Et -});var Ir=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),bt=require('@stdlib/array-index/dist'),E=Sr(),St=w();Ir(E,"factory",St);Ir(E,"idx",bt);module.exports=E; +"use strict";var u=function(r,a){return function(){return a||r((a={exports:{}}).exports,a),a.exports}};var A=u(function(Bt,I){ +var xr=require('@stdlib/array-base-assert-is-complex-floating-point-data-type/dist'),Rr=require('@stdlib/assert-is-number/dist').isPrimitive;function Dr(r){return Rr(r)?[r,0]:r}function kr(r){return xr(r)?Dr:null}I.exports=kr +});var x=u(function(Ft,T){ +function _r(r,a){return i;function i(t){return r(t,a)}}T.exports=_r +});var D=u(function(Lt,R){ +var Pr=require('@stdlib/proxy-ctor/dist'),Nr=typeof Pr=="function";R.exports=Nr +});var _=u(function(Mt,k){ +var Vr=require('@stdlib/array-index/dist');function Ur(){return{cache:Vr,strict:!1}}k.exports=Ur +});var V=u(function(jt,N){ +var Cr=require('@stdlib/assert-is-plain-object/dist'),P=require('@stdlib/assert-has-own-property/dist'),Or=require('@stdlib/assert-is-boolean/dist').isPrimitive,Gr=require('@stdlib/assert-is-method-in/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function Br(r,a){return Cr(a)?P(a,"strict")&&(r.strict=a.strict,!Or(r.strict))?new TypeError(d('1rX2o',"strict",r.strict)):P(a,"cache")&&(r.cache=a.cache,!Gr(r.cache,"get"))?new TypeError(d('1rXFb',"cache","get",r.cache)):null:new TypeError(d('1rX2V',a));}N.exports=Br +});var G=u(function(zt,O){ +var l=require('@stdlib/assert-is-number/dist').isPrimitive,Fr=require('@stdlib/assert-is-integer/dist').isPrimitive,Lr=require('@stdlib/assert-is-boolean/dist').isPrimitive,f=require('@stdlib/assert-is-complex-like/dist'),Mr=require('@stdlib/array-base-assert-is-real-floating-point-data-type/dist'),jr=require('@stdlib/array-base-assert-is-unsigned-integer-data-type/dist'),zr=require('@stdlib/array-base-assert-is-signed-integer-data-type/dist'),Wr=require('@stdlib/array-base-assert-is-boolean-data-type/dist'),U=require('@stdlib/array-base-assert-is-safe-data-type-cast/dist'),C=require('@stdlib/array-min-dtype/dist'),Qr=require('@stdlib/array-base-min-signed-integer-dtype/dist'),q=require('@stdlib/complex-dtype/dist'),c=require('@stdlib/error-tools-fmtprodmsg/dist');function Xr(){return null}function Yr(r,a){return Lr(r)?null:new TypeError(c('1rXEw',typeof r,a));}function $r(r,a){return l(r)?null:f(r)?new TypeError(c('1rXEw',q(r),a)):new TypeError(c('1rXEw',typeof r,a));}function Hr(r,a){return l(r)||f(r)?null:new TypeError(c('1rXEw',typeof r,a));}function Jr(r,a){var i;return l(r)?Fr(r)?(i=Qr(r),U(i,a)?null:new TypeError(c('1rXEw',i,a))):new TypeError(c('1rXEw',C(r),a)):f(r)?new TypeError(c('1rXEw',q(r),a)):new TypeError(c('1rXEw',typeof r,a));}function Kr(r,a){var i;return l(r)?(i=C(r),U(i,a)?null:new TypeError(c('1rXEw',i,a))):f(r)?new TypeError(c('1rXEw',q(r),a)):new TypeError(c('1rXEw',typeof r,a));}function Zr(r){return r==="generic"||r===""?Xr:Mr(r)?$r:jr(r)?Kr:zr(r)?Jr:Wr(r)?Yr:Hr}O.exports=Zr +});var F=u(function(Wt,B){ +function re(r,a){return i;function i(t,n){var s,e;switch(e=n,e.length){case 0:s=new t;break;case 1:s=new t(e[0]);break;case 2:s=new t(e[0],e[1]);break;case 3:s=new t(e[0],e[1],e[2]);break;case 4:s=new t(e[0],e[1],e[2],e[3]);break;case 5:s=new t(e[0],e[1],e[2],e[3],e[4]);break;case 6:s=new t(e[0],e[1],e[2],e[3],e[4],e[5]);break;case 7:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6]);break;case 8:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]);break;case 9:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]);break;case 10:s=new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9]);break;default:s=t.apply(null,e)}return r(s,a)}}B.exports=re +});var M=u(function(Qt,L){ +var ee=/^-?[0-9]+$/;L.exports=ee +});var g=u(function(Xt,j){ +var te=require('@stdlib/assert-is-string/dist').isPrimitive,ie=M();function ae(r){return te(r)&&ie.test(r)}j.exports=ae +});var W=u(function(Yt,z){ +var ne=/\s*ArrayIndex<[^>]+>\s*/;z.exports=ne +});var m=u(function($t,Q){ +var se=require('@stdlib/assert-is-string/dist').isPrimitive,ue=W();function oe(r){return se(r)&&ue.test(r)}Q.exports=oe +});var h=u(function(Ht,X){ +var ce=require('@stdlib/string-base-trim/dist'),ve=require('@stdlib/error-tools-fmtprodmsg/dist');function le(r){return r.substring(11,r.length-1)}function fe(r,a){var i=a.get(le(ce(r)));if(i===null)throw new Error(ve('1rXFa',r));return i}X.exports=fe +});var $=u(function(Jt,Y){ +var pe=require('@stdlib/array-take/dist'),ye=require('@stdlib/array-mskfilter/dist'),de=require('@stdlib/array-mskreject/dist'),qe=require('@stdlib/error-tools-fmtprodmsg/dist'),ge=h();function me(r,a,i){var t=ge(a,i.cache);if(t.type==="int")return i.postGetArray(pe(r,t.data));if(t.type==="bool")return i.postGetArray(ye(r,t.data));if(t.type==="mask")return i.postGetArray(de(r,t.data));throw new Error(qe('1rXFZ',t.type))}Y.exports=me +});var w=u(function(Kt,H){ +var he=require('@stdlib/ndarray-base-normalize-index/dist'),we=require('@stdlib/error-tools-fmtprodmsg/dist');function Ee(r,a,i){var t,n;if(t=parseInt(r,10),n=he(t,a-1),n===-1){if(i)throw new RangeError(we('1rXFY'));return t}return n}H.exports=Ee +});var K=u(function(Zt,J){ +var be=w();function Se(r,a,i){return i.getter(r,be(a,r.length,i.strict))}J.exports=Se +});var rr=u(function(ri,Z){ +var Ie=require('@stdlib/assert-is-function/dist');function Ae(r,a,i,t){var n=r[a];if(Ie(n))return n===r.constructor?t.ctor:s;return n;function s(){var e,o;for(e=[],o=0;o1&&(s=br(n,arguments[1]),s))throw s;return e=bt(t),o=e.dtype||"",v={ref:t,dtype:o,getter:e.accessors[0],setter:e.accessors[1],preSetElement:At(o),postGetArray:Tt(i,n),cache:n.cache,strict:n.strict,validator:Dt(o),array2fancy:i,ctor:new Er(t.constructor||Array,{construct:kt(i,n)})},new Er(t,{get:_t(v),set:Pt(v)})}return console.warn("WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available."),t}}Sr.exports=Nt +});var Ar=u(function(fi,Ir){ +var Vt=b(),Ut=Vt();Ir.exports=Ut +});var Tr=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),Ct=require('@stdlib/array-index/dist'),S=Ar(),Ot=b();Tr(S,"factory",Ot);Tr(S,"idx",Ct);module.exports=S; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map index ce757f1..c6e60ad 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../lib/set_element_wrapper.js", "../lib/get_array_wrapper.js", "../lib/has_proxy_support.js", "../lib/defaults.js", "../lib/validate.js", "../lib/validator.js", "../lib/ctor.js", "../lib/re_integer.js", "../lib/is_integer_string.js", "../lib/re_array_index.js", "../lib/is_array_index_string.js", "../lib/prop2array.js", "../lib/get_elements.js", "../lib/resolve_index.js", "../lib/get_element.js", "../lib/get_value.js", "../lib/error_message.js", "../lib/re_subseq.js", "../lib/prop2slice.js", "../lib/get_slice.js", "../lib/get.js", "../lib/set_element.js", "../lib/set_value.js", "../lib/set_slice.js", "../lib/set.js", "../lib/factory.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\n\n\n// FUNCTIONS //\n\n/**\n* Normalizes values assigned to complex number arrays.\n*\n* @private\n* @param {*} value - input value\n* @returns {(ComplexLike|*)} output value\n*/\nfunction wrapComplex( value ) {\n\t// Wrap real-valued scalars as valid input arguments to complex number arrays...\n\tif ( isNumber( value ) ) {\n\t\treturn [ value, 0.0 ]; // note: we're assuming that a ComplexXXArray setter accepts an array of interleaved real and imaginary components\n\t}\n\t// For everything other than a real-valued scalar, we delegate validation to the target complex number array:\n\treturn value;\n}\n\n\n// MAIN //\n\n/**\n* Returns a wrapper function for processing scalar input values before assignment.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {(Function|null)} wrapper function or null\n*/\nfunction wrapper( dtype ) {\n\tif ( isComplexDataType( dtype ) ) {\n\t\treturn wrapComplex;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = wrapper;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the 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 wrapper function for processing arrays after retrieval.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @param {Function} opts.cache - cache for resolving array index objects\n* @returns {Function} wrapper function\n*/\nfunction wrapper( array2fancy, opts ) {\n\treturn wrap;\n\n\t/**\n\t* Returns a proxied array.\n\t*\n\t* @private\n\t* @param {Array} x - input array\n\t* @returns {Array} proxied array\n\t*/\n\tfunction wrap( x ) {\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = wrapper;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Proxy = require( '@stdlib/proxy-ctor' );\n\n\n// MAIN //\n\n/**\n* Boolean indicating if an environment has Proxy support.\n*\n* @private\n* @name hasSupport\n* @type {boolean}\n*/\nvar hasSupport = ( typeof Proxy === 'function' ); // NOTE: cannot use `@stdlib/assert/has-proxy-support` here, as that API uses code evaluation and might violate CSPs; consequently, this is a relatively weak check for proxy support\n\n\n// EXPORTS //\n\nmodule.exports = hasSupport;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar ArrayIndex = require( '@stdlib/array-index' );\n\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'cache': ArrayIndex,\n\t\t'strict': false\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isMethodIn = require( '@stdlib/assert-is-method-in' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'strict': false\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\topts.strict = options.strict;\n\t\tif ( !isBoolean( opts.strict ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', opts.strict ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'cache' ) ) {\n\t\topts.cache = options.cache;\n\t\tif ( !isMethodIn( opts.cache, 'get' ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option is missing a `%s` method. Option: `%s`.', 'cache', 'get', opts.cache ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isRealFloatingDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' );\nvar isUnsignedIntegerDataType = require( '@stdlib/array-base-assert-is-unsigned-integer-data-type' );\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isSafeCast = require( '@stdlib/array-base-assert-is-safe-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDataType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a \"generic\" or unknown data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {null} null\n*\n* @example\n* var err = validateGeneric( 3, 'generic' );\n* // returns null\n*/\nfunction validateGeneric() {\n\treturn null;\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array have a real-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateRealFloating( 3.14, 'float64' );\n* // returns null\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var err = validateRealFloating( new Complex128( 5.0, 6.0 ), 'float64' );\n* // returns \n*/\nfunction validateRealFloating( value, dtype ) {\n\tif ( isNumber( value ) ) {\n\t\treturn null;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array have a complex-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var err = validateComplexFloating( new Complex128( 5.0, 6.0 ), 'complex128' );\n* // returns null\n*\n* @example\n* var err = validateComplexFloating( {}, 'complex128' );\n* // returns \n*/\nfunction validateComplexFloating( value, dtype ) {\n\tif ( isNumber( value ) || isComplexLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array have a signed integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateSignedInteger( 3, 'int32' );\n* // returns null\n*\n* @example\n* var err = validateSignedInteger( 3.14, 'int32' );\n* // returns \n*/\nfunction validateSignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tif ( !isInteger( value ) ) {\n\t\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', minDataType( value ), dtype ) );\n\t\t}\n\t\tvdt = minSignedIntegerDataType( value );\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array have an unsigned integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateUnsignedInteger( 3, 'uint32' );\n* // returns null\n*\n* @example\n* var err = validateUnsignedInteger( -3, 'uint32' );\n* // returns \n*/\nfunction validateUnsignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tvdt = minDataType( value ); // note: we rely on data type resolution to handle the case where `value` is a non-integer value. In that case, `vdt` will resolve to a floating-point data type and `isSafeCast` will evaluate to `false`\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n\n// MAIN //\n\n/**\n* Returns a validation function for verifying whether a provided value can be safely assigned to an element in an array having a specified data type.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {Function} validation function\n*\n* @example\n* var fcn = validator( 'int32' );\n*\n* var err = fcn( 3, 'int32' );\n* // returns null\n*\n* err = fcn( 3.14, 'int32' );\n* // returns \n*/\nfunction validator( dtype ) {\n\tif ( dtype === 'generic' || dtype === '' ) {\n\t\treturn validateGeneric;\n\t}\n\tif ( isRealFloatingDataType( dtype ) ) {\n\t\treturn validateRealFloating;\n\t}\n\tif ( isUnsignedIntegerDataType( dtype ) ) {\n\t\treturn validateUnsignedInteger;\n\t}\n\tif ( isSignedIntegerDataType( dtype ) ) {\n\t\treturn validateSignedInteger;\n\t}\n\t// Case: isComplexDataType( dtype ) === true\n\treturn validateComplexFloating;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the 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 trap for constructing new array instances.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @returns {Function} handler\n*/\nfunction factory( array2fancy, opts ) {\n\treturn constructor;\n\n\t/**\n\t* Trap for constructing new array instances.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {Array} args - list of constructor arguments\n\t* @param {Object} newTarget - constructor that was originally called\n\t* @returns {*} new instance\n\t*/\n\tfunction constructor( target, args ) {\n\t\tvar x;\n\t\tvar a;\n\n\t\ta = args;\n\t\tswitch ( a.length ) {\n\t\tcase 0:\n\t\t\tx = new target();\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tx = new target( a[0] );\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tx = new target( a[0], a[1] );\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tx = new target( a[0], a[1], a[2] );\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tx = new target( a[0], a[1], a[2], a[3] );\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4] );\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5] );\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6] );\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] );\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// Fallback to using `apply`; however, some constructors may error if the constructor is not callable (i.e., if a constructor always requires `new`):\n\t\t\tx = target.apply( null, a );\n\t\t}\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is an integer string.\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*\n* @example\n* var bool = RE_INTEGER.test( '10' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '-1' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '0:10:2' );\n* // returns false\n*/\nvar RE_INTEGER = /^-?[0-9]+$/;\n\n\n// EXPORTS //\n\nmodule.exports = RE_INTEGER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 RE_INTEGER = require( './re_integer.js' );\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is an integer.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isIntegerString( '1' );\n* // returns true\n*\n* @example\n* var out = isIntegerString( ':' );\n* // returns false\n*/\nfunction isIntegerString( prop ) {\n\treturn ( isString( prop ) && RE_INTEGER.test( prop ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isIntegerString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a serialized array index.\n*\n* @private\n* @name RE_ARRAY_INDEX\n* @type {RegExp}\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_ARRAY_INDEX = /\\s*ArrayIndex<[^>]+>\\s*/;\n\n\n// EXPORTS //\n\nmodule.exports = RE_ARRAY_INDEX;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 RE_ARRAY_INDEX = require( './re_array_index.js' );\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is a serialized array index.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isArrayIndexString( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var out = isArrayIndexString( ':' );\n* // returns false\n*/\nfunction isArrayIndexString( prop ) {\n\treturn ( isString( prop ) && RE_ARRAY_INDEX.test( prop ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isArrayIndexString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar trim = require( '@stdlib/string-base-trim' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Extracts an array index identifier from an array index indexing expression.\n*\n* @private\n* @param {string} str - input string\n* @returns {string} identifier\n*\n* @example\n* var str = 'ArrayIndex<0>';\n*\n* var id = getIdentifier( str );\n* // returns '0'\n*/\nfunction getIdentifier( str ) {\n\treturn str.substring( 11, str.length-1 ); // ArrayIndex => XX\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to an array index.\n*\n* @private\n* @param {string} property - property name\n* @param {Object} cache - cache for resolving array index objects\n* @throws {Error} invalid array index\n* @returns {(Object|null)} index object (or null)\n*/\nfunction prop2array( property, cache ) {\n\tvar o = cache.get( getIdentifier( trim( property ) ) );\n\tif ( o === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unable to resolve array index. Value: `%s`.', property ) );\n\t}\n\treturn o;\n}\n\n\n// EXPORTS //\n\nmodule.exports = prop2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar take = require( '@stdlib/array-take' );\nvar mskfilter = require( '@stdlib/array-mskfilter' );\nvar mskreject = require( '@stdlib/array-mskreject' );\nvar format = require( '@stdlib/string-format' );\nvar prop2array = require( './prop2array.js' );\n\n\n// MAIN //\n\n/**\n* Returns the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @returns {Collection} result\n*/\nfunction getElements( target, property, ctx ) {\n\tvar idx = prop2array( property, ctx.cache );\n\tif ( idx.type === 'int' ) {\n\t\treturn ctx.postGetArray( take( target, idx.data ) );\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\treturn ctx.postGetArray( mskfilter( target, idx.data ) );\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\treturn ctx.postGetArray( mskreject( target, idx.data ) );\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = getElements;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Resolves an integer index from an integer string.\n*\n* @private\n* @param {string} str - integer string\n* @param {NonNegativeInteger} max - index upper bound (exclusive)\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} index exceeds array bounds\n* @returns {integer} integer index\n*\n* @example\n* var idx = resolveIndex( '-1', 10, false );\n* // returns 9\n*\n* @example\n* var idx = resolveIndex( '-20', 10, false );\n* // returns -20\n*/\nfunction resolveIndex( str, max, strict ) {\n\tvar idx;\n\tvar i;\n\n\tidx = parseInt( str, 10 );\n\ti = normalizeIndex( idx, max-1 );\n\tif ( i === -1 ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid operation. Index exceeds array bounds.' ) );\n\t\t}\n\t\t// Return the non-normalized index, as this should fallback to default property handling and returning \"undefined\":\n\t\treturn idx;\n\t}\n\treturn i;\n}\n\n\n// EXPORTS //\n\nmodule.exports = resolveIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveIndex = require( './resolve_index.js' );\n\n\n// MAIN //\n\n/**\n* Returns the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @returns {*} result\n*/\nfunction getElement( target, property, ctx ) {\n\treturn ctx.getter( target, resolveIndex( property, target.length, ctx.strict ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = getElement;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\n\n\n// MAIN //\n\n/**\n* Returns the property value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {(string|symbol)} property - property\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {Function} ctx.ctor - proxied array constructor\n* @returns {*} result\n*/\nfunction getValue( target, property, receiver, ctx ) {\n\tvar value = target[ property ];\n\tif ( isFunction( value ) ) {\n\t\tif ( value === target.constructor ) {\n\t\t\treturn ctx.ctor;\n\t\t}\n\t\treturn wrapper;\n\t}\n\treturn value;\n\n\t/**\n\t* Method wrapper.\n\t*\n\t* @private\n\t* @returns {*} results\n\t*/\n\tfunction wrapper() {\n\t\tvar args;\n\t\tvar i;\n\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn value.apply( ( this === receiver ) ? target : this, args ); // eslint-disable-line no-invalid-this\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getValue;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\n\n\n// MAIN //\n\n/**\n* Returns an updated error message for trapped errors.\n*\n* @private\n* @param {string} msg - error message\n* @returns {string} updated message\n*/\nfunction errMessage( msg ) {\n\treturn replace( msg, /^invalid arguments?/, 'invalid operation' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = errMessage;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a subsequence string.\n*\n* @private\n* @name RE_SUBSEQ\n* @type {RegExp}\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0:10:2' );\n* // returns true\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_SUBSEQ.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_SUBSEQ = /:/;\n\n\n// EXPORTS //\n\nmodule.exports = RE_SUBSEQ;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar trim = require( '@stdlib/string-base-trim' );\nvar seq2slice = require( '@stdlib/slice-base-seq2slice' );\nvar str2slice = require( '@stdlib/slice-base-str2slice' );\nvar startsWith = require( '@stdlib/string-base-starts-with' );\nvar format = require( '@stdlib/string-format' );\nvar RE_SUBSEQ = require( './re_subseq.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Tests if an indexing expression is a serialized Slice object.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSlice( 'Slice(null,null,1)' );\n* // returns true\n*\n* @example\n* var out = isSlice( ':' );\n* // returns false\n*/\nfunction isSlice( prop ) {\n\treturn (\n\t\tprop[ 0 ] === 'S' &&\n\t\tstartsWith( prop, 'Slice(', 0 ) &&\n\t\tprop[ prop.length-1 ] === ')'\n\t);\n}\n\n/**\n* Tests if an indexing expression is a subsequence.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSubsequence( '::-2' );\n* // returns true\n*\n* @example\n* var out = isSubsequence( '-2' );\n* // returns false\n*/\nfunction isSubsequence( prop ) {\n\t// TODO: consider whether to make this check more robust (e.g., should we actually throw if someone tries to access `foo:bar`? If we make this check more exact, how would we distinguish between a non-existent `foo:bar` property and an actual error in the subsequence string?)\n\treturn RE_SUBSEQ.test( prop );\n}\n\n/**\n* Parses a serialized Slice object.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - serialized Slice object\n* @throws {Error} invalid slice operation\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSlice( ' Slice(null,null,1) ', 'Slice(null,null,1)' );\n* // returns \n*/\nfunction parseSlice( raw, str ) {\n\tvar s = str2slice( str );\n\tif ( s === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t}\n\treturn s;\n}\n\n/**\n* Parses a subsequence string.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - subsequence string\n* @param {NonNegativeInteger} max - index upper bound\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSubsequence( ' ::-2 ', '::-2', 10, false );\n* // returns \n*/\nfunction parseSubsequence( raw, str, max, strict ) {\n\tvar s = seq2slice( str, max, true );\n\tif ( s.code ) {\n\t\tif ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) {\n\t\t\tthrow new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', raw ) );\n\t\t}\n\t\tif ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) {\n\t\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t\t}\n\t\t// NOTE: the following error check must come last due to fall-through when in non-strict mode...\n\t\tif ( s.code === 'ERR_SLICE_OUT_OF_BOUNDS' ) {\n\t\t\tif ( strict ) {\n\t\t\t\tthrow new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) );\n\t\t\t}\n\t\t\t// Repeat parsing, this time allowing for out-of-bounds slices:\n\t\t\ts = seq2slice( str, max, false );\n\t\t}\n\t}\n\treturn s;\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to a Slice object.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Slice|null)} slice object (or null)\n*/\nfunction prop2slice( target, property, strict ) {\n\tvar prop = trim( property );\n\tif ( isSlice( prop ) ) {\n\t\treturn parseSlice( property, prop );\n\t}\n\tif ( isSubsequence( prop ) ) {\n\t\treturn parseSubsequence( property, prop, target.length, strict );\n\t}\n\t// Everything else (including undefined/non-existent properties):\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = prop2slice;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar slice = require( '@stdlib/array-base-fancy-slice' );\nvar errMessage = require( './error_message.js' );\nvar prop2slice = require( './prop2slice.js' );\n\n\n// MAIN //\n\n/**\n* Returns a copy.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {Object} ctx - context object\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Collection|void)} result\n*/\nfunction getSlice( target, property, ctx ) {\n\tvar s = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// Ensure consistency with normal array behavior by returning `undefined` for any \"unrecognized\" property name:\n\t\treturn;\n\t}\n\ttry {\n\t\treturn ctx.postGetArray( slice( target, s, ctx.strict ) );\n\t} catch ( err ) {\n\t\t// In principle, we should only error when in \"strict\" mode and a slice exceeds array bounds...\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getSlice;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 hasProperty = require( '@stdlib/assert-has-property' );\nvar isIntegerString = require( './is_integer_string.js' );\nvar isArrayIndexString = require( './is_array_index_string.js' );\nvar getElements = require( './get_elements.js' );\nvar getElement = require( './get_element.js' );\nvar getValue = require( './get_value.js' );\nvar getSlice = require( './get_slice.js' );\n\n\n// MAIN //\n\n/**\n* Returns a trap for retrieving property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.ctor - proxied array constructor\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn get;\n\n\t/**\n\t* Trap for retrieving property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {RangeError} slice exceeds array bounds\n\t* @throws {RangeError} index exceeds array bounds\n\t* @returns {*} result\n\t*/\n\tfunction get( target, property, receiver ) {\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn getElement( target, property, ctx );\n\t\t}\n\t\tif ( hasProperty( target, property ) || !isString( property ) ) {\n\t\t\treturn getValue( target, property, receiver, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn getElements( target, property, ctx );\n\t\t}\n\t\treturn getSlice( target, property, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveIndex = require( './resolve_index.js' );\n\n\n// MAIN //\n\n/**\n* Sets the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value\n* @param {Object} ctx - context object\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {string} ctx.dtype - target array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElement( target, property, value, ctx ) {\n\tvar err;\n\tvar v;\n\n\terr = ctx.validator( value, ctx.dtype );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( ctx.preSetElement ) {\n\t\tv = ctx.preSetElement( value );\n\t} else {\n\t\tv = value;\n\t}\n\tctx.setter( target, resolveIndex( property, target.length, ctx.strict ), v ); // eslint-disable-line max-len\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setElement;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets the value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property\n* @param {*} value - new value\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setValue( target, property, value ) {\n\ttarget[ property ] = value;\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setValue;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 sliceAssign = require( '@stdlib/array-base-fancy-slice-assign' );\nvar scalar2array = require( '@stdlib/array-from-scalar' );\nvar prop2slice = require( './prop2slice.js' );\nvar errMessage = require( './error_message.js' );\n\n\n// MAIN //\n\n/**\n* Sets element values belonging to the array view specified by an indexing expression.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - indexing expression\n* @param {*} value - new value\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array view\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setSlice( target, property, value, receiver, ctx ) {\n\tvar err;\n\tvar s;\n\tvar v;\n\n\ts = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// If unable to parse the property as an indexing expression, signal that we were unable to perform slice assignment:\n\t\treturn false;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to `sliceAssign` (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, ctx.dtype );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during slice assignment:\n\t\tv = scalar2array( value, ctx.dtype );\n\t}\n\ttry {\n\t\tsliceAssign( v, receiver, s, ctx.strict );\n\t\treturn true;\n\t} catch ( err ) {\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setSlice;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 hasProperty = require( '@stdlib/assert-has-property' );\nvar isIntegerString = require( './is_integer_string.js' );\nvar setElement = require( './set_element.js' );\nvar setValue = require( './set_value.js' );\nvar setSlice = require( './set_slice.js' );\n\n\n// MAIN //\n\n/**\n* Returns a trap for setting property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn set;\n\n\t/**\n\t* Trap for setting property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {*} value - new value\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {Error} assigned value must be broadcast compatible with output array view\n\t* @throws {TypeError} assigned value cannot be safely cast to the output array data type\n\t* @throws {TypeError} slice exceeds array bounds\n\t* @throws {TypeError} index exceeds array bounds\n\t* @returns {boolean} boolean indicating whether assignment succeeded\n\t*/\n\tfunction set( target, property, value, receiver ) {\n\t\tvar out;\n\n\t\t// Note that we need to check for an integer string *before* checking for an own property, as we want to explicitly handle *all* indexed properties, not just negative integers, in order to perform assignment validation...\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn setElement( target, property, value, ctx );\n\t\t}\n\t\tif ( hasProperty( property ) || !isString( property ) ) {\n\t\t\treturn setValue( target, property, value, ctx );\n\t\t}\n\t\tout = setSlice( target, property, value, receiver, ctx );\n\t\tif ( out ) {\n\t\t\treturn out;\n\t\t}\n\t\t// If we were unsuccessful (e.g., due to an invalid subsequence, etc), set the \"property\" in the same way as would any normal property (e.g., if an indexing expression is an invalid subsequence, assign as would a regular property: `i = 'a:b:c'` => `x[i] = 1` => `v = x[i]` => `v === 1`):\n\t\treturn setValue( target, property, value, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar Proxy = require( '@stdlib/proxy-ctor' );\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar assign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar setElementWrapper = require( './set_element_wrapper.js' );\nvar getArrayWrapper = require( './get_array_wrapper.js' );\nvar hasProxySupport = require( './has_proxy_support.js' );\nvar defaults = require( './defaults.js' );\nvar validate = require( './validate.js' );\nvar validator = require( './validator.js' );\nvar ctor = require( './ctor.js' );\nvar get = require( './get.js' );\nvar set = require( './set.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for converting an array to an object supporting fancy indexing.\n*\n* @param {Options} options - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking by default\n* @param {Function} [options.cache] - default cache for resolving array index objects\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} function for converting an array to an object supporting fancy indexing\n*\n* @example\n* var array2fancy = factory();\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nfunction factory() {\n\tvar OPTIONS;\n\tvar err;\n\n\tOPTIONS = defaults();\n\tif ( arguments.length ) {\n\t\terr = validate( OPTIONS, arguments[ 0 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn array2fancy;\n\n\t/**\n\t* Converts an array to an object supporting fancy indexing.\n\t*\n\t* @private\n\t* @param {ArrayLike} x - input array\n\t* @param {Options} [options] - function options\n\t* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n\t* @param {Function} [options.cache] - cache for resolving array index objects\n\t* @throws {TypeError} first argument must be array-like\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {ArrayLike} fancy array\n\t*\n\t* @example\n\t* var x = [ 1, 2, 3, 4, 5, 6 ];\n\t*\n\t* var y = array2fancy( x );\n\t* // returns \n\t*\n\t* var z = y[ '1::2' ];\n\t* // returns [ 2, 4, 6 ]\n\t*\n\t* var len = z.length;\n\t* // returns 3\n\t*\n\t* var v = z[ 0 ];\n\t* // returns 2\n\t*\n\t* v = z[ 1 ];\n\t* // returns 4\n\t*\n\t* v = z[ 2 ];\n\t* // returns 6\n\t*/\n\tfunction array2fancy( x ) {\n\t\tvar opts;\n\t\tvar err;\n\t\tvar arr;\n\t\tvar dt;\n\t\tvar o;\n\t\tif ( !isArrayLike( x ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be array-like. Value: `%s`.', x ) );\n\t\t}\n\t\tif ( hasProxySupport ) {\n\t\t\topts = assign( {}, OPTIONS );\n\t\t\tif ( arguments.length > 1 ) {\n\t\t\t\terr = validate( opts, arguments[ 1 ] );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t\tarr = arraylike2object( x );\n\t\t\tdt = arr.dtype || '';\n\t\t\to = {\n\t\t\t\t'ref': x,\n\t\t\t\t'dtype': dt,\n\t\t\t\t'getter': arr.accessors[ 0 ],\n\t\t\t\t'setter': arr.accessors[ 1 ],\n\t\t\t\t'preSetElement': setElementWrapper( dt ),\n\t\t\t\t'postGetArray': getArrayWrapper( array2fancy, opts ),\n\t\t\t\t'cache': opts.cache,\n\t\t\t\t'strict': opts.strict,\n\t\t\t\t'validator': validator( dt ),\n\t\t\t\t'array2fancy': array2fancy,\n\t\t\t\t'ctor': new Proxy( x.constructor || Array, {\n\t\t\t\t\t'construct': ctor( array2fancy, opts )\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn new Proxy( x, {\n\t\t\t\t'get': get( o ),\n\t\t\t\t'set': set( o )\n\t\t\t});\n\t\t}\n\t\t// TODO: replace with `@stdlib/console/warn` (or equivalent once available)\n\t\tconsole.warn( 'WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available.' ); // eslint-disable-line no-console\n\t\treturn x;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\n/**\n* Converts an array to an object supporting fancy indexing.\n*\n* @name array2fancy\n* @type {Function}\n* @param {ArrayLike} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @throws {TypeError} first argument must be array-like\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayLike} fancy array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nvar array2fancy = factory();\n\n\n// EXPORTS //\n\nmodule.exports = array2fancy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Convert an array to an object supporting fancy indexing.\n*\n* @module @stdlib/array-to-fancy\n*\n* @example\n* var array2fancy = require( '@stdlib/array-to-fancy' );\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar ArrayIndex = require( '@stdlib/array-index' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\nsetReadOnly( main, 'idx', ArrayIndex );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAoB,QAAS,+DAAgE,EAC7FC,GAAW,QAAS,0BAA2B,EAAE,YAYrD,SAASC,GAAaC,EAAQ,CAE7B,OAAKF,GAAUE,CAAM,EACb,CAAEA,EAAO,CAAI,EAGdA,CACR,CAYA,SAASC,GAASC,EAAQ,CACzB,OAAKL,GAAmBK,CAAM,EACtBH,GAED,IACR,CAKAH,EAAO,QAAUK,KChEjB,IAAAE,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAgCA,SAASC,GAASC,EAAaC,EAAO,CACrC,OAAOC,EASP,SAASA,EAAMC,EAAI,CAClB,OAAOH,EAAaG,EAAGF,CAAK,CAC7B,CACD,CAKAH,EAAO,QAAUC,KClDjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAQ,QAAS,oBAAqB,EAYtCC,GAAe,OAAOD,IAAU,WAKpCD,EAAO,QAAUE,KCvCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAa,QAAS,qBAAsB,EAehD,SAASC,IAAW,CACnB,MAAO,CACN,MAASD,GACT,OAAU,EACX,CACD,CAKAD,EAAO,QAAUE,KC/CjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,GAAY,QAAS,2BAA4B,EAAE,YACnDC,GAAa,QAAS,6BAA8B,EACpDC,EAAS,QAAS,uBAAwB,EAyB9C,SAASC,GAAUC,EAAMC,EAAU,CAClC,OAAMP,GAAUO,CAAQ,EAGnBN,EAAYM,EAAS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,4HAA6H,EACpIJ,CACR,CACD,CAKAnB,GAAO,QAAUe,KCxKjB,IAAAS,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAU,IAwCVC,GAAcD,GAAQ,EAK1BD,GAAO,QAAUE,KChBjB,IAAIC,GAAc,QAAS,uDAAwD,EAC/EC,GAAa,QAAS,qBAAsB,EAC5CC,EAAO,KACPC,GAAU,IAKdH,GAAaE,EAAM,UAAWC,EAAQ,EACtCH,GAAaE,EAAM,MAAOD,EAAW,EAKrC,OAAO,QAAUC", - "names": ["require_set_element_wrapper", "__commonJSMin", "exports", "module", "isComplexDataType", "isNumber", "wrapComplex", "value", "wrapper", "dtype", "require_get_array_wrapper", "__commonJSMin", "exports", "module", "wrapper", "array2fancy", "opts", "wrap", "x", "require_has_proxy_support", "__commonJSMin", "exports", "module", "Proxy", "hasSupport", "require_defaults", "__commonJSMin", "exports", "module", "ArrayIndex", "defaults", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isMethodIn", "format", "validate", "opts", "options", "require_validator", "__commonJSMin", "exports", "module", "isNumber", "isInteger", "isComplexLike", "isRealFloatingDataType", "isUnsignedIntegerDataType", "isSignedIntegerDataType", "isSafeCast", "minDataType", "minSignedIntegerDataType", "complexDataType", "format", "validateGeneric", "validateRealFloating", "value", "dtype", "validateComplexFloating", "validateSignedInteger", "vdt", "validateUnsignedInteger", "validator", "require_ctor", "__commonJSMin", "exports", "module", "factory", "array2fancy", "opts", "constructor", "target", "args", "x", "a", "require_re_integer", "__commonJSMin", "exports", "module", "RE_INTEGER", "require_is_integer_string", "__commonJSMin", "exports", "module", "isString", "RE_INTEGER", "isIntegerString", "prop", "require_re_array_index", "__commonJSMin", "exports", "module", "RE_ARRAY_INDEX", "require_is_array_index_string", "__commonJSMin", "exports", "module", "isString", "RE_ARRAY_INDEX", "isArrayIndexString", "prop", "require_prop2array", "__commonJSMin", "exports", "module", "trim", "format", "getIdentifier", "str", "prop2array", "property", "cache", "o", "require_get_elements", "__commonJSMin", "exports", "module", "take", "mskfilter", "mskreject", "format", "prop2array", "getElements", "target", "property", "ctx", "idx", "require_resolve_index", "__commonJSMin", "exports", "module", "normalizeIndex", "format", "resolveIndex", "str", "max", "strict", "idx", "i", "require_get_element", "__commonJSMin", "exports", "module", "resolveIndex", "getElement", "target", "property", "ctx", "require_get_value", "__commonJSMin", "exports", "module", "isFunction", "getValue", "target", "property", "receiver", "ctx", "value", "wrapper", "args", "i", "require_error_message", "__commonJSMin", "exports", "module", "replace", "errMessage", "msg", "require_re_subseq", "__commonJSMin", "exports", "module", "RE_SUBSEQ", "require_prop2slice", "__commonJSMin", "exports", "module", "trim", "seq2slice", "str2slice", "startsWith", "format", "RE_SUBSEQ", "isSlice", "prop", "isSubsequence", "parseSlice", "raw", "str", "s", "parseSubsequence", "max", "strict", "prop2slice", "target", "property", "require_get_slice", "__commonJSMin", "exports", "module", "slice", "errMessage", "prop2slice", "getSlice", "target", "property", "ctx", "s", "err", "require_get", "__commonJSMin", "exports", "module", "isString", "hasProperty", "isIntegerString", "isArrayIndexString", "getElements", "getElement", "getValue", "getSlice", "factory", "ctx", "get", "target", "property", "receiver", "require_set_element", "__commonJSMin", "exports", "module", "resolveIndex", "setElement", "target", "property", "value", "ctx", "err", "v", "require_set_value", "__commonJSMin", "exports", "module", "setValue", "target", "property", "value", "require_set_slice", "__commonJSMin", "exports", "module", "isCollection", "sliceAssign", "scalar2array", "prop2slice", "errMessage", "setSlice", "target", "property", "value", "receiver", "ctx", "err", "s", "v", "require_set", "__commonJSMin", "exports", "module", "isString", "hasProperty", "isIntegerString", "setElement", "setValue", "setSlice", "factory", "ctx", "set", "target", "property", "value", "receiver", "out", "require_factory", "__commonJSMin", "exports", "module", "isArrayLike", "Proxy", "arraylike2object", "assign", "format", "setElementWrapper", "getArrayWrapper", "hasProxySupport", "defaults", "validate", "validator", "ctor", "get", "set", "factory", "OPTIONS", "err", "array2fancy", "x", "opts", "arr", "dt", "o", "require_main", "__commonJSMin", "exports", "module", "factory", "array2fancy", "setReadOnly", "ArrayIndex", "main", "factory"] + "sources": ["../lib/set_element_wrapper.js", "../lib/get_array_wrapper.js", "../lib/has_proxy_support.js", "../lib/defaults.js", "../lib/validate.js", "../lib/validator.js", "../lib/ctor.js", "../lib/re_integer.js", "../lib/is_integer_string.js", "../lib/re_array_index.js", "../lib/is_array_index_string.js", "../lib/prop2array.js", "../lib/get_elements.js", "../lib/resolve_index.js", "../lib/get_element.js", "../lib/get_value.js", "../lib/error_message.js", "../lib/re_subseq.js", "../lib/prop2slice.js", "../lib/get_slice.js", "../lib/get.js", "../lib/set_elements.js", "../lib/set_element.js", "../lib/set_value.js", "../lib/set_slice.js", "../lib/set.js", "../lib/factory.js", "../lib/main.js", "../lib/index.js"], + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\n\n\n// FUNCTIONS //\n\n/**\n* Normalizes values assigned to complex number arrays.\n*\n* @private\n* @param {*} value - input value\n* @returns {(ComplexLike|*)} output value\n*/\nfunction wrapComplex( value ) {\n\t// Wrap real-valued scalars as valid input arguments to complex number arrays...\n\tif ( isNumber( value ) ) {\n\t\treturn [ value, 0.0 ]; // note: we're assuming that a ComplexXXArray setter accepts an array of interleaved real and imaginary components\n\t}\n\t// For everything other than a real-valued scalar, we delegate validation to the target complex number array:\n\treturn value;\n}\n\n\n// MAIN //\n\n/**\n* Returns a wrapper function for processing scalar input values before assignment.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {(Function|null)} wrapper function or null\n*/\nfunction wrapper( dtype ) {\n\tif ( isComplexDataType( dtype ) ) {\n\t\treturn wrapComplex;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = wrapper;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the 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 wrapper function for processing arrays after retrieval.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @param {Function} opts.cache - cache for resolving array index objects\n* @returns {Function} wrapper function\n*/\nfunction wrapper( array2fancy, opts ) {\n\treturn wrap;\n\n\t/**\n\t* Returns a proxied array.\n\t*\n\t* @private\n\t* @param {Array} x - input array\n\t* @returns {Array} proxied array\n\t*/\n\tfunction wrap( x ) {\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = wrapper;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Proxy = require( '@stdlib/proxy-ctor' );\n\n\n// MAIN //\n\n/**\n* Boolean indicating if an environment has Proxy support.\n*\n* @private\n* @name hasSupport\n* @type {boolean}\n*/\nvar hasSupport = ( typeof Proxy === 'function' ); // NOTE: cannot use `@stdlib/assert/has-proxy-support` here, as that API uses code evaluation and might violate CSPs; consequently, this is a relatively weak check for proxy support\n\n\n// EXPORTS //\n\nmodule.exports = hasSupport;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar ArrayIndex = require( '@stdlib/array-index' );\n\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'cache': ArrayIndex,\n\t\t'strict': false\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isMethodIn = require( '@stdlib/assert-is-method-in' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'strict': false\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\topts.strict = options.strict;\n\t\tif ( !isBoolean( opts.strict ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', opts.strict ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'cache' ) ) {\n\t\topts.cache = options.cache;\n\t\tif ( !isMethodIn( opts.cache, 'get' ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option is missing a `%s` method. Option: `%s`.', 'cache', 'get', opts.cache ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isRealFloatingDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' );\nvar isUnsignedIntegerDataType = require( '@stdlib/array-base-assert-is-unsigned-integer-data-type' );\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isSafeCast = require( '@stdlib/array-base-assert-is-safe-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDataType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a \"generic\" or unknown data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {null} null\n*\n* @example\n* var err = validateGeneric( 3, 'generic' );\n* // returns null\n*/\nfunction validateGeneric() {\n\treturn null;\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a boolean data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateBoolean( true, 'bool' );\n* // returns null\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var err = validateBoolean( new Complex128( 5.0, 6.0 ), 'bool' );\n* // returns \n*/\nfunction validateBoolean( value, dtype ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a real-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateRealFloating( 3.14, 'float64' );\n* // returns null\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var err = validateRealFloating( new Complex128( 5.0, 6.0 ), 'float64' );\n* // returns \n*/\nfunction validateRealFloating( value, dtype ) {\n\tif ( isNumber( value ) ) {\n\t\treturn null;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a complex-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var err = validateComplexFloating( new Complex128( 5.0, 6.0 ), 'complex128' );\n* // returns null\n*\n* @example\n* var err = validateComplexFloating( {}, 'complex128' );\n* // returns \n*/\nfunction validateComplexFloating( value, dtype ) {\n\tif ( isNumber( value ) || isComplexLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a signed integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateSignedInteger( 3, 'int32' );\n* // returns null\n*\n* @example\n* var err = validateSignedInteger( 3.14, 'int32' );\n* // returns \n*/\nfunction validateSignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tif ( !isInteger( value ) ) {\n\t\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', minDataType( value ), dtype ) );\n\t\t}\n\t\tvdt = minSignedIntegerDataType( value );\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having an unsigned integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateUnsignedInteger( 3, 'uint32' );\n* // returns null\n*\n* @example\n* var err = validateUnsignedInteger( -3, 'uint32' );\n* // returns \n*/\nfunction validateUnsignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tvdt = minDataType( value ); // note: we rely on data type resolution to handle the case where `value` is a non-integer value. In that case, `vdt` will resolve to a floating-point data type and `isSafeCast` will evaluate to `false`\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n\n// MAIN //\n\n/**\n* Returns a validation function for verifying whether a provided value can be safely assigned to an element in an array having a specified data type.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {Function} validation function\n*\n* @example\n* var fcn = validator( 'int32' );\n*\n* var err = fcn( 3, 'int32' );\n* // returns null\n*\n* err = fcn( 3.14, 'int32' );\n* // returns \n*/\nfunction validator( dtype ) {\n\tif ( dtype === 'generic' || dtype === '' ) {\n\t\treturn validateGeneric;\n\t}\n\tif ( isRealFloatingDataType( dtype ) ) {\n\t\treturn validateRealFloating;\n\t}\n\tif ( isUnsignedIntegerDataType( dtype ) ) {\n\t\treturn validateUnsignedInteger;\n\t}\n\tif ( isSignedIntegerDataType( dtype ) ) {\n\t\treturn validateSignedInteger;\n\t}\n\tif ( isBooleanDataType( dtype ) ) {\n\t\treturn validateBoolean;\n\t}\n\t// Case: isComplexDataType( dtype ) === true\n\treturn validateComplexFloating;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the 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 trap for constructing new array instances.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @returns {Function} handler\n*/\nfunction factory( array2fancy, opts ) {\n\treturn constructor;\n\n\t/**\n\t* Trap for constructing new array instances.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {Array} args - list of constructor arguments\n\t* @param {Object} newTarget - constructor that was originally called\n\t* @returns {*} new instance\n\t*/\n\tfunction constructor( target, args ) {\n\t\tvar x;\n\t\tvar a;\n\n\t\ta = args;\n\t\tswitch ( a.length ) {\n\t\tcase 0:\n\t\t\tx = new target();\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tx = new target( a[0] );\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tx = new target( a[0], a[1] );\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tx = new target( a[0], a[1], a[2] );\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tx = new target( a[0], a[1], a[2], a[3] );\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4] );\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5] );\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6] );\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] );\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// Fallback to using `apply`; however, some constructors may error if the constructor is not callable (i.e., if a constructor always requires `new`):\n\t\t\tx = target.apply( null, a );\n\t\t}\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is an integer string.\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*\n* @example\n* var bool = RE_INTEGER.test( '10' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '-1' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '0:10:2' );\n* // returns false\n*/\nvar RE_INTEGER = /^-?[0-9]+$/;\n\n\n// EXPORTS //\n\nmodule.exports = RE_INTEGER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 RE_INTEGER = require( './re_integer.js' );\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is an integer.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isIntegerString( '1' );\n* // returns true\n*\n* @example\n* var out = isIntegerString( ':' );\n* // returns false\n*/\nfunction isIntegerString( prop ) {\n\treturn ( isString( prop ) && RE_INTEGER.test( prop ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isIntegerString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a serialized array index.\n*\n* @private\n* @name RE_ARRAY_INDEX\n* @type {RegExp}\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_ARRAY_INDEX = /\\s*ArrayIndex<[^>]+>\\s*/;\n\n\n// EXPORTS //\n\nmodule.exports = RE_ARRAY_INDEX;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 RE_ARRAY_INDEX = require( './re_array_index.js' );\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is a serialized array index.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isArrayIndexString( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var out = isArrayIndexString( ':' );\n* // returns false\n*/\nfunction isArrayIndexString( prop ) {\n\treturn ( isString( prop ) && RE_ARRAY_INDEX.test( prop ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isArrayIndexString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar trim = require( '@stdlib/string-base-trim' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Extracts an array index identifier from an array index indexing expression.\n*\n* @private\n* @param {string} str - input string\n* @returns {string} identifier\n*\n* @example\n* var str = 'ArrayIndex<0>';\n*\n* var id = getIdentifier( str );\n* // returns '0'\n*/\nfunction getIdentifier( str ) {\n\treturn str.substring( 11, str.length-1 ); // ArrayIndex => XX\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to an array index.\n*\n* @private\n* @param {string} property - property name\n* @param {Object} cache - cache for resolving array index objects\n* @throws {Error} invalid array index\n* @returns {(Object|null)} index object (or null)\n*/\nfunction prop2array( property, cache ) {\n\tvar o = cache.get( getIdentifier( trim( property ) ) );\n\tif ( o === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unable to resolve array index. Value: `%s`.', property ) );\n\t}\n\treturn o;\n}\n\n\n// EXPORTS //\n\nmodule.exports = prop2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar take = require( '@stdlib/array-take' );\nvar mskfilter = require( '@stdlib/array-mskfilter' );\nvar mskreject = require( '@stdlib/array-mskreject' );\nvar format = require( '@stdlib/string-format' );\nvar prop2array = require( './prop2array.js' );\n\n\n// MAIN //\n\n/**\n* Returns the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @returns {Collection} result\n*/\nfunction getElements( target, property, ctx ) {\n\tvar idx = prop2array( property, ctx.cache );\n\tif ( idx.type === 'int' ) {\n\t\treturn ctx.postGetArray( take( target, idx.data ) );\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\treturn ctx.postGetArray( mskfilter( target, idx.data ) );\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\treturn ctx.postGetArray( mskreject( target, idx.data ) );\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = getElements;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Resolves an integer index from an integer string.\n*\n* @private\n* @param {string} str - integer string\n* @param {NonNegativeInteger} max - index upper bound (exclusive)\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} index exceeds array bounds\n* @returns {integer} integer index\n*\n* @example\n* var idx = resolveIndex( '-1', 10, false );\n* // returns 9\n*\n* @example\n* var idx = resolveIndex( '-20', 10, false );\n* // returns -20\n*/\nfunction resolveIndex( str, max, strict ) {\n\tvar idx;\n\tvar i;\n\n\tidx = parseInt( str, 10 );\n\ti = normalizeIndex( idx, max-1 );\n\tif ( i === -1 ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid operation. Index exceeds array bounds.' ) );\n\t\t}\n\t\t// Return the non-normalized index, as this should fallback to default property handling and returning \"undefined\":\n\t\treturn idx;\n\t}\n\treturn i;\n}\n\n\n// EXPORTS //\n\nmodule.exports = resolveIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveIndex = require( './resolve_index.js' );\n\n\n// MAIN //\n\n/**\n* Returns the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @returns {*} result\n*/\nfunction getElement( target, property, ctx ) {\n\treturn ctx.getter( target, resolveIndex( property, target.length, ctx.strict ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = getElement;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\n\n\n// MAIN //\n\n/**\n* Returns the property value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {(string|symbol)} property - property\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {Function} ctx.ctor - proxied array constructor\n* @returns {*} result\n*/\nfunction getValue( target, property, receiver, ctx ) {\n\tvar value = target[ property ];\n\tif ( isFunction( value ) ) {\n\t\tif ( value === target.constructor ) {\n\t\t\treturn ctx.ctor;\n\t\t}\n\t\treturn wrapper;\n\t}\n\treturn value;\n\n\t/**\n\t* Method wrapper.\n\t*\n\t* @private\n\t* @returns {*} results\n\t*/\n\tfunction wrapper() {\n\t\tvar args;\n\t\tvar i;\n\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn value.apply( ( this === receiver ) ? target : this, args ); // eslint-disable-line no-invalid-this\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getValue;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\n\n\n// MAIN //\n\n/**\n* Returns an updated error message for trapped errors.\n*\n* @private\n* @param {string} msg - error message\n* @returns {string} updated message\n*/\nfunction errMessage( msg ) {\n\treturn replace( msg, /^invalid arguments?/, 'invalid operation' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = errMessage;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a subsequence string.\n*\n* @private\n* @name RE_SUBSEQ\n* @type {RegExp}\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0:10:2' );\n* // returns true\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_SUBSEQ.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_SUBSEQ = /:/;\n\n\n// EXPORTS //\n\nmodule.exports = RE_SUBSEQ;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar trim = require( '@stdlib/string-base-trim' );\nvar seq2slice = require( '@stdlib/slice-base-seq2slice' );\nvar str2slice = require( '@stdlib/slice-base-str2slice' );\nvar startsWith = require( '@stdlib/string-base-starts-with' );\nvar format = require( '@stdlib/string-format' );\nvar RE_SUBSEQ = require( './re_subseq.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Tests if an indexing expression is a serialized Slice object.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSlice( 'Slice(null,null,1)' );\n* // returns true\n*\n* @example\n* var out = isSlice( ':' );\n* // returns false\n*/\nfunction isSlice( prop ) {\n\treturn (\n\t\tprop[ 0 ] === 'S' &&\n\t\tstartsWith( prop, 'Slice(', 0 ) &&\n\t\tprop[ prop.length-1 ] === ')'\n\t);\n}\n\n/**\n* Tests if an indexing expression is a subsequence.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSubsequence( '::-2' );\n* // returns true\n*\n* @example\n* var out = isSubsequence( '-2' );\n* // returns false\n*/\nfunction isSubsequence( prop ) {\n\t// TODO: consider whether to make this check more robust (e.g., should we actually throw if someone tries to access `foo:bar`? If we make this check more exact, how would we distinguish between a non-existent `foo:bar` property and an actual error in the subsequence string?)\n\treturn RE_SUBSEQ.test( prop );\n}\n\n/**\n* Parses a serialized Slice object.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - serialized Slice object\n* @throws {Error} invalid slice operation\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSlice( ' Slice(null,null,1) ', 'Slice(null,null,1)' );\n* // returns \n*/\nfunction parseSlice( raw, str ) {\n\tvar s = str2slice( str );\n\tif ( s === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t}\n\treturn s;\n}\n\n/**\n* Parses a subsequence string.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - subsequence string\n* @param {NonNegativeInteger} max - index upper bound\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSubsequence( ' ::-2 ', '::-2', 10, false );\n* // returns \n*/\nfunction parseSubsequence( raw, str, max, strict ) {\n\tvar s = seq2slice( str, max, true );\n\tif ( s.code ) {\n\t\tif ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) {\n\t\t\tthrow new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', raw ) );\n\t\t}\n\t\tif ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) {\n\t\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t\t}\n\t\t// NOTE: the following error check must come last due to fall-through when in non-strict mode...\n\t\tif ( s.code === 'ERR_SLICE_OUT_OF_BOUNDS' ) {\n\t\t\tif ( strict ) {\n\t\t\t\tthrow new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) );\n\t\t\t}\n\t\t\t// Repeat parsing, this time allowing for out-of-bounds slices:\n\t\t\ts = seq2slice( str, max, false );\n\t\t}\n\t}\n\treturn s;\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to a Slice object.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Slice|null)} slice object (or null)\n*/\nfunction prop2slice( target, property, strict ) {\n\tvar prop = trim( property );\n\tif ( isSlice( prop ) ) {\n\t\treturn parseSlice( property, prop );\n\t}\n\tif ( isSubsequence( prop ) ) {\n\t\treturn parseSubsequence( property, prop, target.length, strict );\n\t}\n\t// Everything else (including undefined/non-existent properties):\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = prop2slice;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar slice = require( '@stdlib/array-base-fancy-slice' );\nvar errMessage = require( './error_message.js' );\nvar prop2slice = require( './prop2slice.js' );\n\n\n// MAIN //\n\n/**\n* Returns a copy.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {Object} ctx - context object\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Collection|void)} result\n*/\nfunction getSlice( target, property, ctx ) {\n\tvar s = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// Ensure consistency with normal array behavior by returning `undefined` for any \"unrecognized\" property name:\n\t\treturn;\n\t}\n\ttry {\n\t\treturn ctx.postGetArray( slice( target, s, ctx.strict ) );\n\t} catch ( err ) {\n\t\t// In principle, we should only error when in \"strict\" mode and a slice exceeds array bounds...\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getSlice;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 hasProperty = require( '@stdlib/assert-has-property' );\nvar isIntegerString = require( './is_integer_string.js' );\nvar isArrayIndexString = require( './is_array_index_string.js' );\nvar getElements = require( './get_elements.js' );\nvar getElement = require( './get_element.js' );\nvar getValue = require( './get_value.js' );\nvar getSlice = require( './get_slice.js' );\n\n\n// MAIN //\n\n/**\n* Returns a trap for retrieving property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.ctor - proxied array constructor\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn get;\n\n\t/**\n\t* Trap for retrieving property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {RangeError} slice exceeds array bounds\n\t* @throws {RangeError} index exceeds array bounds\n\t* @returns {*} result\n\t*/\n\tfunction get( target, property, receiver ) {\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn getElement( target, property, ctx );\n\t\t}\n\t\tif ( hasProperty( target, property ) || !isString( property ) ) {\n\t\t\treturn getValue( target, property, receiver, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn getElements( target, property, ctx );\n\t\t}\n\t\treturn getSlice( target, property, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 scalar2array = require( '@stdlib/array-from-scalar' );\nvar put = require( '@stdlib/array-put' );\nvar format = require( '@stdlib/string-format' );\nvar prop2array = require( './prop2array.js' );\nvar errMessage = require( './error_message.js' );\n\n\n// MAIN //\n\n/**\n* Replaces the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value(s)\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array selection\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElements( target, property, value, ctx ) {\n\tvar idx;\n\tvar err;\n\tvar v;\n\n\tidx = prop2array( property, ctx.cache );\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to implementation APIs (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, ctx.dtype );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tif ( ctx.preSetElement ) {\n\t\t\tv = ctx.preSetElement( value );\n\t\t} else {\n\t\t\tv = value;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during assignment:\n\t\tv = scalar2array( v, ctx.dtype );\n\t}\n\tif ( idx.type === 'int' ) {\n\t\ttry {\n\t\t\tput( target, idx.data, v );\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\t// FIXME: where( idx.data, target, value );\n\t\treturn false;\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\t// FIXME: where( idx.data, value, target );\n\t\treturn false;\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = setElements;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveIndex = require( './resolve_index.js' );\n\n\n// MAIN //\n\n/**\n* Sets the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value\n* @param {Object} ctx - context object\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {string} ctx.dtype - target array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElement( target, property, value, ctx ) {\n\tvar err;\n\tvar v;\n\n\terr = ctx.validator( value, ctx.dtype );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( ctx.preSetElement ) {\n\t\tv = ctx.preSetElement( value );\n\t} else {\n\t\tv = value;\n\t}\n\tctx.setter( target, resolveIndex( property, target.length, ctx.strict ), v ); // eslint-disable-line max-len\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setElement;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets the value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property\n* @param {*} value - new value\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setValue( target, property, value ) {\n\ttarget[ property ] = value;\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setValue;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 sliceAssign = require( '@stdlib/array-base-fancy-slice-assign' );\nvar scalar2array = require( '@stdlib/array-from-scalar' );\nvar prop2slice = require( './prop2slice.js' );\nvar errMessage = require( './error_message.js' );\n\n\n// MAIN //\n\n/**\n* Sets element values belonging to the array view specified by an indexing expression.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - indexing expression\n* @param {*} value - new value\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array view\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setSlice( target, property, value, receiver, ctx ) {\n\tvar err;\n\tvar s;\n\tvar v;\n\n\ts = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// If unable to parse the property as an indexing expression, signal that we were unable to perform slice assignment:\n\t\treturn false;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to `sliceAssign` (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, ctx.dtype );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during slice assignment:\n\t\tv = scalar2array( value, ctx.dtype );\n\t}\n\ttry {\n\t\tsliceAssign( v, receiver, s, ctx.strict );\n\t} catch ( err ) {\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setSlice;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 hasProperty = require( '@stdlib/assert-has-property' );\nvar isIntegerString = require( './is_integer_string.js' );\nvar isArrayIndexString = require( './is_array_index_string.js' );\nvar setElements = require( './set_elements.js' );\nvar setElement = require( './set_element.js' );\nvar setValue = require( './set_value.js' );\nvar setSlice = require( './set_slice.js' );\n\n\n// MAIN //\n\n/**\n* Returns a trap for setting property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn set;\n\n\t/**\n\t* Trap for setting property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {*} value - new value\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {Error} assigned value must be broadcast compatible with output array view\n\t* @throws {TypeError} assigned value cannot be safely cast to the output array data type\n\t* @throws {TypeError} slice exceeds array bounds\n\t* @throws {TypeError} index exceeds array bounds\n\t* @returns {boolean} boolean indicating whether assignment succeeded\n\t*/\n\tfunction set( target, property, value, receiver ) {\n\t\tvar out;\n\n\t\t// Note that we need to check for an integer string *before* checking for an own property, as we want to explicitly handle *all* indexed properties, not just negative integers, in order to perform assignment validation...\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn setElement( target, property, value, ctx );\n\t\t}\n\t\tif ( hasProperty( property ) || !isString( property ) ) {\n\t\t\treturn setValue( target, property, value, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn setElements( target, property, value, ctx );\n\t\t}\n\t\tout = setSlice( target, property, value, receiver, ctx );\n\t\tif ( out ) {\n\t\t\treturn out;\n\t\t}\n\t\t// If we were unsuccessful (e.g., due to an invalid subsequence, etc), set the \"property\" in the same way as would any normal property (e.g., if an indexing expression is an invalid subsequence, assign as would a regular property: `i = 'a:b:c'` => `x[i] = 1` => `v = x[i]` => `v === 1`):\n\t\treturn setValue( target, property, value, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar Proxy = require( '@stdlib/proxy-ctor' );\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar assign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar setElementWrapper = require( './set_element_wrapper.js' );\nvar getArrayWrapper = require( './get_array_wrapper.js' );\nvar hasProxySupport = require( './has_proxy_support.js' );\nvar defaults = require( './defaults.js' );\nvar validate = require( './validate.js' );\nvar validator = require( './validator.js' );\nvar ctor = require( './ctor.js' );\nvar get = require( './get.js' );\nvar set = require( './set.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for converting an array to an object supporting fancy indexing.\n*\n* @param {Options} options - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking by default\n* @param {Function} [options.cache] - default cache for resolving array index objects\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} function for converting an array to an object supporting fancy indexing\n*\n* @example\n* var array2fancy = factory();\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nfunction factory() {\n\tvar OPTIONS;\n\tvar err;\n\n\tOPTIONS = defaults();\n\tif ( arguments.length ) {\n\t\terr = validate( OPTIONS, arguments[ 0 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn array2fancy;\n\n\t/**\n\t* Converts an array to an object supporting fancy indexing.\n\t*\n\t* @private\n\t* @param {ArrayLike} x - input array\n\t* @param {Options} [options] - function options\n\t* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n\t* @param {Function} [options.cache] - cache for resolving array index objects\n\t* @throws {TypeError} first argument must be array-like\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {ArrayLike} fancy array\n\t*\n\t* @example\n\t* var x = [ 1, 2, 3, 4, 5, 6 ];\n\t*\n\t* var y = array2fancy( x );\n\t* // returns \n\t*\n\t* var z = y[ '1::2' ];\n\t* // returns [ 2, 4, 6 ]\n\t*\n\t* var len = z.length;\n\t* // returns 3\n\t*\n\t* var v = z[ 0 ];\n\t* // returns 2\n\t*\n\t* v = z[ 1 ];\n\t* // returns 4\n\t*\n\t* v = z[ 2 ];\n\t* // returns 6\n\t*/\n\tfunction array2fancy( x ) {\n\t\tvar opts;\n\t\tvar err;\n\t\tvar arr;\n\t\tvar dt;\n\t\tvar o;\n\t\tif ( !isArrayLike( x ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be array-like. Value: `%s`.', x ) );\n\t\t}\n\t\tif ( hasProxySupport ) {\n\t\t\topts = assign( {}, OPTIONS );\n\t\t\tif ( arguments.length > 1 ) {\n\t\t\t\terr = validate( opts, arguments[ 1 ] );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t\tarr = arraylike2object( x );\n\t\t\tdt = arr.dtype || '';\n\t\t\to = {\n\t\t\t\t'ref': x,\n\t\t\t\t'dtype': dt,\n\t\t\t\t'getter': arr.accessors[ 0 ],\n\t\t\t\t'setter': arr.accessors[ 1 ],\n\t\t\t\t'preSetElement': setElementWrapper( dt ),\n\t\t\t\t'postGetArray': getArrayWrapper( array2fancy, opts ),\n\t\t\t\t'cache': opts.cache,\n\t\t\t\t'strict': opts.strict,\n\t\t\t\t'validator': validator( dt ),\n\t\t\t\t'array2fancy': array2fancy,\n\t\t\t\t'ctor': new Proxy( x.constructor || Array, {\n\t\t\t\t\t'construct': ctor( array2fancy, opts )\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn new Proxy( x, {\n\t\t\t\t'get': get( o ),\n\t\t\t\t'set': set( o )\n\t\t\t});\n\t\t}\n\t\t// TODO: replace with `@stdlib/console/warn` (or equivalent once available)\n\t\tconsole.warn( 'WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available.' ); // eslint-disable-line no-console\n\t\treturn x;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\n/**\n* Converts an array to an object supporting fancy indexing.\n*\n* @name array2fancy\n* @type {Function}\n* @param {ArrayLike} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @throws {TypeError} first argument must be array-like\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayLike} fancy array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nvar array2fancy = factory();\n\n\n// EXPORTS //\n\nmodule.exports = array2fancy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Convert an array to an object supporting fancy indexing.\n*\n* @module @stdlib/array-to-fancy\n*\n* @example\n* var array2fancy = require( '@stdlib/array-to-fancy' );\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar ArrayIndex = require( '@stdlib/array-index' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\nsetReadOnly( main, 'idx', ArrayIndex );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAoB,QAAS,+DAAgE,EAC7FC,GAAW,QAAS,0BAA2B,EAAE,YAYrD,SAASC,GAAaC,EAAQ,CAE7B,OAAKF,GAAUE,CAAM,EACb,CAAEA,EAAO,CAAI,EAGdA,CACR,CAYA,SAASC,GAASC,EAAQ,CACzB,OAAKL,GAAmBK,CAAM,EACtBH,GAED,IACR,CAKAH,EAAO,QAAUK,KChEjB,IAAAE,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAgCA,SAASC,GAASC,EAAaC,EAAO,CACrC,OAAOC,EASP,SAASA,EAAMC,EAAI,CAClB,OAAOH,EAAaG,EAAGF,CAAK,CAC7B,CACD,CAKAH,EAAO,QAAUC,KClDjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAQ,QAAS,oBAAqB,EAYtCC,GAAe,OAAOD,IAAU,WAKpCD,EAAO,QAAUE,KCvCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAa,QAAS,qBAAsB,EAehD,SAASC,IAAW,CACnB,MAAO,CACN,MAASD,GACT,OAA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AASA,EAAK,MACd,OAAUA,EAAK,OACf,UAAaT,GAAWW,CAAG,EAC3B,YAAeJ,EACf,KAAQ,IAAIhB,GAAOiB,EAAE,aAAe,MAAO,CAC1C,UAAaP,GAAMM,EAAaE,CAAK,CACtC,CAAC,CACF,EACO,IAAIlB,GAAOiB,EAAG,CACpB,IAAON,GAAKU,CAAE,EACd,IAAOT,GAAKS,CAAE,CACf,CAAC,CACF,CAEA,eAAQ,KAAM,4HAA6H,EACpIJ,CACR,CACD,CAKAnB,GAAO,QAAUe,KCxKjB,IAAAS,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAU,IAwCVC,GAAcD,GAAQ,EAK1BD,GAAO,QAAUE,KChBjB,IAAIC,GAAc,QAAS,uDAAwD,EAC/EC,GAAa,QAAS,qBAAsB,EAC5CC,EAAO,KACPC,GAAU,IAKdH,GAAaE,EAAM,UAAWC,EAAQ,EACtCH,GAAaE,EAAM,MAAOD,EAAW,EAKrC,OAAO,QAAUC", + "names": ["require_set_element_wrapper", "__commonJSMin", "exports", "module", "isComplexDataType", "isNumber", "wrapComplex", "value", "wrapper", "dtype", "require_get_array_wrapper", "__commonJSMin", "exports", "module", "wrapper", "array2fancy", "opts", "wrap", "x", "require_has_proxy_support", "__commonJSMin", "exports", "module", "Proxy", "hasSupport", "require_defaults", "__commonJSMin", "exports", "module", "ArrayIndex", "defaults", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isMethodIn", "format", "validate", "opts", "options", "require_validator", "__commonJSMin", "exports", "module", "isNumber", "isInteger", "isBoolean", "isComplexLike", "isRealFloatingDataType", "isUnsignedIntegerDataType", "isSignedIntegerDataType", "isBooleanDataType", "isSafeCast", "minDataType", "minSignedIntegerDataType", "complexDataType", "format", "validateGeneric", "validateBoolean", "value", "dtype", "validateRealFloating", "validateComplexFloating", "validateSignedInteger", "vdt", "validateUnsignedInteger", "validator", "require_ctor", "__commonJSMin", "exports", "module", "factory", "array2fancy", "opts", "constructor", "target", "args", "x", "a", "require_re_integer", "__commonJSMin", "exports", "module", "RE_INTEGER", "require_is_integer_string", "__commonJSMin", "exports", "module", "isString", "RE_INTEGER", "isIntegerString", "prop", "require_re_array_index", "__commonJSMin", "exports", "module", "RE_ARRAY_INDEX", "require_is_array_index_string", "__commonJSMin", "exports", "module", "isString", "RE_ARRAY_INDEX", "isArrayIndexString", "prop", "require_prop2array", "__commonJSMin", "exports", "module", "trim", "format", "getIdentifier", "str", "prop2array", "property", "cache", "o", "require_get_elements", "__commonJSMin", "exports", "module", "take", "mskfilter", "mskreject", "format", "prop2array", "getElements", "target", "property", "ctx", "idx", "require_resolve_index", "__commonJSMin", "exports", "module", "normalizeIndex", "format", "resolveIndex", "str", "max", "strict", "idx", "i", "require_get_element", "__commonJSMin", "exports", "module", "resolveIndex", "getElement", "target", "property", "ctx", "require_get_value", "__commonJSMin", "exports", "module", "isFunction", "getValue", "target", "property", "receiver", "ctx", "value", "wrapper", "args", "i", "require_error_message", "__commonJSMin", "exports", "module", "replace", "errMessage", "msg", "require_re_subseq", "__commonJSMin", "exports", "module", "RE_SUBSEQ", "require_prop2slice", "__commonJSMin", "exports", "module", "trim", "seq2slice", "str2slice", "startsWith", "format", "RE_SUBSEQ", "isSlice", "prop", "isSubsequence", "parseSlice", "raw", "str", "s", "parseSubsequence", "max", "strict", "prop2slice", "target", "property", "require_get_slice", "__commonJSMin", "exports", "module", "slice", "errMessage", "prop2slice", "getSlice", "target", "property", "ctx", "s", "err", "require_get", "__commonJSMin", "exports", "module", "isString", "hasProperty", "isIntegerString", "isArrayIndexString", "getElements", "getElement", "getValue", "getSlice", "factory", "ctx", "get", "target", "property", "receiver", "require_set_elements", "__commonJSMin", "exports", "module", "isCollection", "scalar2array", "put", "format", "prop2array", "errMessage", "setElements", "target", "property", "value", "ctx", "idx", "err", "v", "require_set_element", "__commonJSMin", "exports", "module", "resolveIndex", "setElement", "target", "property", "value", "ctx", "err", "v", "require_set_value", "__commonJSMin", "exports", "module", "setValue", "target", "property", "value", "require_set_slice", "__commonJSMin", "exports", "module", "isCollection", "sliceAssign", "scalar2array", "prop2slice", "errMessage", "setSlice", "target", "property", "value", "receiver", "ctx", "err", "s", "v", "require_set", "__commonJSMin", "exports", "module", "isString", "hasProperty", "isIntegerString", "isArrayIndexString", "setElements", "setElement", "setValue", "setSlice", "factory", "ctx", "set", "target", "property", "value", "receiver", "out", "require_factory", "__commonJSMin", "exports", "module", "isArrayLike", "Proxy", "arraylike2object", "assign", "format", "setElementWrapper", "getArrayWrapper", "hasProxySupport", "defaults", "validate", "validator", "ctor", "get", "set", "factory", "OPTIONS", "err", "array2fancy", "x", "opts", "arr", "dt", "o", "require_main", "__commonJSMin", "exports", "module", "factory", "array2fancy", "setReadOnly", "ArrayIndex", "main", "factory"] } diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index c4b1388..5c9ab7a 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { Collection, ArrayLike, AccessorArrayLike, Complex128Array, Complex64Array, ArrayIndexObject } from '@stdlib/types/array'; +import { Collection, ArrayLike, AccessorArrayLike, ComplexTypedArray, TypedArray, BooleanTypedArray, ArrayIndexObject } from '@stdlib/types/array'; import ArrayIndex = require( '@stdlib/array-index' ); /** @@ -74,17 +74,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1.0, 2.0, 3.0, 4.0 ] - */ - ( x: Float64Array, options?: Options ): Float64Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Float32Array = require( '@stdlib/array-float32' ); @@ -96,17 +85,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1.0, 2.0, 3.0, 4.0 ] - */ - ( x: Float32Array, options?: Options ): Float32Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Complex128Array = require( '@stdlib/array-complex128' ); @@ -118,17 +96,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1.0, 2.0, 3.0, 4.0 ] - */ - ( x: Complex128Array, options?: Options ): Complex128Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Complex64Array = require( '@stdlib/array-complex64' ); @@ -140,17 +107,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1.0, 2.0, 3.0, 4.0 ] - */ - ( x: Complex64Array, options?: Options ): Complex64Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Int32Array = require( '@stdlib/array-int32' ); @@ -162,17 +118,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] - */ - ( x: Int32Array, options?: Options ): Int32Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Int16Array = require( '@stdlib/array-int16' ); @@ -184,17 +129,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] - */ - ( x: Int16Array, options?: Options ): Int16Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Int8Array = require( '@stdlib/array-int8' ); @@ -206,17 +140,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] - */ - ( x: Int8Array, options?: Options ): Int8Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Uint32Array = require( '@stdlib/array-uint32' ); @@ -228,17 +151,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] - */ - ( x: Uint32Array, options?: Options ): Uint32Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Uint16Array = require( '@stdlib/array-uint16' ); @@ -250,17 +162,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] - */ - ( x: Uint16Array, options?: Options ): Uint16Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Uint8Array = require( '@stdlib/array-uint8' ); @@ -272,17 +173,6 @@ interface Array2Fancy { * * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] - */ - ( x: Uint8Array, options?: Options ): Uint8Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array * * @example * var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); @@ -295,7 +185,7 @@ interface Array2Fancy { * var v = y[ ':' ]; * // returns [ 1, 2, 3, 4 ] */ - ( x: Uint8ClampedArray, options?: Options ): Uint8ClampedArray; + ( x: T, options?: Options ): T; /** * Converts an array to an object supporting fancy indexing. diff --git a/docs/types/test.ts b/docs/types/test.ts index 184f378..ee3ece4 100644 --- a/docs/types/test.ts +++ b/docs/types/test.ts @@ -38,6 +38,7 @@ import array2fancy = require( './index' ); array2fancy( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType Uint8ClampedArray array2fancy( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex128Array array2fancy( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex64Array + array2fancy( new BooleanArray( [ true, false, true ] ) ); // $ExpectType BooleanArray const opts = { 'strict': true @@ -54,6 +55,7 @@ import array2fancy = require( './index' ); array2fancy( new Uint8ClampedArray( [ 1, 2, 3 ] ), opts ); // $ExpectType Uint8ClampedArray array2fancy( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), opts ); // $ExpectType Complex128Array array2fancy( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), opts ); // $ExpectType Complex64Array + array2fancy( new BooleanArray( [ true, false, true ] ), opts ); // $ExpectType BooleanArray } // The compiler throws an error if the function is provided a first argument which is not an array-like value... diff --git a/examples/index.js b/examples/index.js index 13b9200..48f9e62 100644 --- a/examples/index.js +++ b/examples/index.js @@ -20,6 +20,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var Int32Array = require( '@stdlib/array-int32' ); +var BooleanArray = require( '@stdlib/array-bool' ); var array2fancy = require( './../lib' ); var x = [ 1, 2, 3, 4, 5, 6 ]; @@ -63,6 +64,11 @@ z = y[ i ]; console.log( z ); // => [ 1, -9, -8, 6 ] +i = idx( new BooleanArray( [ true, false, false, true, true, true ] ) ); // boolean array +z = y[ i ]; +console.log( z ); +// => [ 1, -9, -8, 6 ] + i = idx( new Uint8Array( [ 0, 0, 1, 0, 0, 1 ] ) ); // mask array z = y[ i ]; console.log( z ); diff --git a/lib/get_elements.js b/lib/get_elements.js index 9280287..939d772 100644 --- a/lib/get_elements.js +++ b/lib/get_elements.js @@ -36,7 +36,6 @@ var prop2array = require( './prop2array.js' ); * @param {Object} target - target object * @param {string} property - index string * @param {Object} ctx - context object -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking * @param {Object} ctx.cache - cache for resolving array index objects * @param {Function} ctx.postGetArray - function to process a retrieved array * @throws {Error} invalid array index diff --git a/lib/set.js b/lib/set.js index c2186ef..fb53299 100644 --- a/lib/set.js +++ b/lib/set.js @@ -23,6 +23,8 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var hasProperty = require( '@stdlib/assert-has-property' ); var isIntegerString = require( './is_integer_string.js' ); +var isArrayIndexString = require( './is_array_index_string.js' ); +var setElements = require( './set_elements.js' ); var setElement = require( './set_element.js' ); var setValue = require( './set_value.js' ); var setSlice = require( './set_slice.js' ); @@ -71,6 +73,9 @@ function factory( ctx ) { if ( hasProperty( property ) || !isString( property ) ) { return setValue( target, property, value, ctx ); } + if ( isArrayIndexString( property ) ) { + return setElements( target, property, value, ctx ); + } out = setSlice( target, property, value, receiver, ctx ); if ( out ) { return out; diff --git a/lib/set_elements.js b/lib/set_elements.js new file mode 100644 index 0000000..173434e --- /dev/null +++ b/lib/set_elements.js @@ -0,0 +1,97 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 scalar2array = require( '@stdlib/array-from-scalar' ); +var put = require( '@stdlib/array-put' ); +var format = require( '@stdlib/string-format' ); +var prop2array = require( './prop2array.js' ); +var errMessage = require( './error_message.js' ); + + +// MAIN // + +/** +* Replaces the elements specified by an array index. +* +* @private +* @param {Object} target - target object +* @param {string} property - index string +* @param {*} value - new value(s) +* @param {Object} ctx - context object +* @param {string} ctx.dtype - array data type +* @param {Object} ctx.cache - cache for resolving array index objects +* @param {Function} ctx.validator - function for validating new values +* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary) +* @throws {Error} invalid array index +* @throws {RangeError} index exceeds array bounds +* @throws {Error} assigned value must be broadcast compatible with target array selection +* @throws {TypeError} assigned value cannot be safely cast to the target array data type +* @throws {TypeError} target array must have a supported data type +* @returns {boolean} boolean indicating whether assignment succeeded +*/ +function setElements( target, property, value, ctx ) { + var idx; + var err; + var v; + + idx = prop2array( property, ctx.cache ); + if ( isCollection( value ) ) { + // When handling collections, we delegate to implementation APIs (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here: + v = value; + } else { + // When provided a "scalar", we need to check whether the value can be safely cast to the target array data type: + err = ctx.validator( value, ctx.dtype ); + if ( err ) { + throw err; + } + if ( ctx.preSetElement ) { + v = ctx.preSetElement( value ); + } else { + v = value; + } + // As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during assignment: + v = scalar2array( v, ctx.dtype ); + } + if ( idx.type === 'int' ) { + try { + put( target, idx.data, v ); + } catch ( err ) { + throw new err.constructor( errMessage( err.message ) ); + } + return true; + } + if ( idx.type === 'bool' ) { + // FIXME: where( idx.data, target, value ); + return false; + } + if ( idx.type === 'mask' ) { + // FIXME: where( idx.data, value, target ); + return false; + } + throw new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) ); +} + + +// EXPORTS // + +module.exports = setElements; diff --git a/lib/set_slice.js b/lib/set_slice.js index d0e7610..4f08069 100644 --- a/lib/set_slice.js +++ b/lib/set_slice.js @@ -40,6 +40,7 @@ var errMessage = require( './error_message.js' ); * @param {Object} ctx - context object * @param {string} ctx.dtype - array data type * @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking +* @param {Function} ctx.validator - function for validating new values * @throws {Error} invalid slice operation * @throws {RangeError} slice exceeds array bounds * @throws {Error} assigned value must be broadcast compatible with target array view @@ -71,10 +72,10 @@ function setSlice( target, property, value, receiver, ctx ) { } try { sliceAssign( v, receiver, s, ctx.strict ); - return true; } catch ( err ) { throw new err.constructor( errMessage( err.message ) ); } + return true; } diff --git a/lib/validator.js b/lib/validator.js index 20d1bf5..2d02051 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -22,10 +22,12 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; +var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isRealFloatingDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); var isUnsignedIntegerDataType = require( '@stdlib/array-base-assert-is-unsigned-integer-data-type' ); var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); +var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); var isSafeCast = require( '@stdlib/array-base-assert-is-safe-data-type-cast' ); var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); @@ -52,7 +54,32 @@ function validateGeneric() { } /** -* Verifies whether a provided value can be safely assigned to an element in an array have a real-valued floating-point data type. +* Verifies whether a provided value can be safely assigned to an element in an array having a boolean data type. +* +* @private +* @param {*} value - input value +* @param {string} dtype - array data type +* @returns {(Error|null)} error object or null +* +* @example +* var err = validateBoolean( true, 'bool' ); +* // returns null +* +* @example +* var Complex128 = require( '@stdlib/complex-float64-ctor' ); +* +* var err = validateBoolean( new Complex128( 5.0, 6.0 ), 'bool' ); +* // returns +*/ +function validateBoolean( value, dtype ) { + if ( isBoolean( value ) ) { + return null; + } + return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) ); +} + +/** +* Verifies whether a provided value can be safely assigned to an element in an array having a real-valued floating-point data type. * * @private * @param {*} value - input value @@ -80,7 +107,7 @@ function validateRealFloating( value, dtype ) { } /** -* Verifies whether a provided value can be safely assigned to an element in an array have a complex-valued floating-point data type. +* Verifies whether a provided value can be safely assigned to an element in an array having a complex-valued floating-point data type. * * @private * @param {*} value - input value @@ -105,7 +132,7 @@ function validateComplexFloating( value, dtype ) { } /** -* Verifies whether a provided value can be safely assigned to an element in an array have a signed integer data type. +* Verifies whether a provided value can be safely assigned to an element in an array having a signed integer data type. * * @private * @param {*} value - input value @@ -139,7 +166,7 @@ function validateSignedInteger( value, dtype ) { } /** -* Verifies whether a provided value can be safely assigned to an element in an array have an unsigned integer data type. +* Verifies whether a provided value can be safely assigned to an element in an array having an unsigned integer data type. * * @private * @param {*} value - input value @@ -201,6 +228,9 @@ function validator( dtype ) { if ( isSignedIntegerDataType( dtype ) ) { return validateSignedInteger; } + if ( isBooleanDataType( dtype ) ) { + return validateBoolean; + } // Case: isComplexDataType( dtype ) === true return validateComplexFloating; } diff --git a/package.json b/package.json index f54bb93..6d99025 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", + "@stdlib/array-base-assert-is-boolean-data-type": "github:stdlib-js/array-base-assert-is-boolean-data-type#main", "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", "@stdlib/array-base-assert-is-safe-data-type-cast": "^0.3.1", @@ -51,6 +52,7 @@ "@stdlib/array-min-dtype": "^0.2.1", "@stdlib/array-mskfilter": "^0.1.1", "@stdlib/array-mskreject": "^0.1.1", + "@stdlib/array-put": "github:stdlib-js/array-put#main", "@stdlib/array-take": "^0.1.1", "@stdlib/assert-has-own-property": "^0.2.1", "@stdlib/assert-has-property": "^0.2.1", @@ -80,6 +82,7 @@ }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", + "@stdlib/array-bool": "github:stdlib-js/array-bool#main", "@stdlib/array-complex128": "^0.2.1", "@stdlib/array-complex64": "^0.2.1", "@stdlib/array-filled": "^0.2.1", diff --git a/test/test.set.integer_array.js b/test/test.set.integer_array.js new file mode 100644 index 0000000..ca28e91 --- /dev/null +++ b/test/test.set.integer_array.js @@ -0,0 +1,1864 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); +var isSameComplex128Array = require( '@stdlib/assert-is-same-complex128array' ); +var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); +var Complex128 = require( '@stdlib/complex-float64-ctor' ); +var Float64Array = require( '@stdlib/array-float64' ); +var Float32Array = require( '@stdlib/array-float32' ); +var Int32Array = require( '@stdlib/array-int32' ); +var Int8Array = require( '@stdlib/array-int8' ); +var Uint32Array = require( '@stdlib/array-uint32' ); +var Uint16Array = require( '@stdlib/array-uint16' ); +var Complex128Array = require( '@stdlib/array-complex128' ); +var Complex64Array = require( '@stdlib/array-complex64' ); +var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); +var array2fancy = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasProxySupport() +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an array-like object supporting integer array assignment (generic)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = [ 5, 6, 7, 8 ]; + y[ idx ] = [ 5, 6, 7, 8 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = [ 5, 6, 3, 4 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = [ 1, 5, 6, 4 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = [ 5, 2, 6, 4 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = [ 1, 6, 3, 5 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting integer array assignment ("unknown" dtype, accessor)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( toAccessorArray( x ) ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = [ 5, 6, 7, 8 ]; + y[ idx ] = [ 5, 6, 7, 8 ]; + + t.deepEqual( x, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( toAccessorArray( x ) ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = [ 5, 6, 3, 4 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( x, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( toAccessorArray( x ) ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = [ 1, 5, 6, 4 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( x, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( toAccessorArray( x ) ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = [ 5, 2, 6, 4 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( x, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( toAccessorArray( x ) ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = [ 1, 6, 3, 5 ]; + y[ idx ] = [ 5, 6 ]; + + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting integer array assignment (int32)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Int32Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Int32Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Int32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Int32Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Int32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Int32Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Int32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Int32Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Int32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting integer array assignment (uint32)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Uint32Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Uint32Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Uint32Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Uint32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Uint32Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Uint32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Uint32Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Uint32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Uint32Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Uint32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting integer array assignment (float64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float64Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting integer array assignment (complex128)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); + y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (generic, array)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = [ 5, 5, 5, 5 ]; + y[ idx ] = [ 5 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = [ 5, 5, 3, 4 ]; + y[ idx ] = [ 5 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = [ 1, 5, 5, 4 ]; + y[ idx ] = [ 5 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = [ 5, 2, 5, 4 ]; + y[ idx ] = [ 5 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = [ 1, 5, 3, 5 ]; + y[ idx ] = [ 5 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (generic, scalar)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = [ 5, 5, 5, 5 ]; + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = [ 5, 5, 3, 4 ]; + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = [ 1, 5, 5, 4 ]; + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = [ 5, 2, 5, 4 ]; + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = [ 1, 5, 3, 5 ]; + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (float64, array)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float64Array( [ 5, 5, 5, 5 ] ); + y[ idx ] = new Float64Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Float64Array( [ 5, 5, 3, 4 ] ); + y[ idx ] = new Float64Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float64Array( [ 1, 5, 5, 4 ] ); + y[ idx ] = new Float64Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Float64Array( [ 5, 2, 5, 4 ] ); + y[ idx ] = new Float64Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float64Array( [ 1, 5, 3, 5 ] ); + y[ idx ] = new Float64Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (float64, scalar)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float64Array( [ 5, 5, 5, 5 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Float64Array( [ 5, 5, 3, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float64Array( [ 1, 5, 5, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Float64Array( [ 5, 2, 5, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float64Array( [ 1, 5, 3, 5 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (int32, array)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Int32Array( [ 5, 5, 5, 5 ] ); + y[ idx ] = new Int32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Int32Array( [ 5, 5, 3, 4 ] ); + y[ idx ] = new Int32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Int32Array( [ 1, 5, 5, 4 ] ); + y[ idx ] = new Int32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Int32Array( [ 5, 2, 5, 4 ] ); + y[ idx ] = new Int32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Int32Array( [ 1, 5, 3, 5 ] ); + y[ idx ] = new Int32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (int32, scalar)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Int32Array( [ 5, 5, 5, 5 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Int32Array( [ 5, 5, 3, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Int32Array( [ 1, 5, 5, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Int32Array( [ 5, 2, 5, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Int32Array( [ 1, 5, 3, 5 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (uint32, array)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Uint32Array( [ 5, 5, 5, 5 ] ); + y[ idx ] = new Uint32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Uint32Array( [ 5, 5, 3, 4 ] ); + y[ idx ] = new Uint32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Uint32Array( [ 1, 5, 5, 4 ] ); + y[ idx ] = new Uint32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Uint32Array( [ 5, 2, 5, 4 ] ); + y[ idx ] = new Uint32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Uint32Array( [ 1, 5, 3, 5 ] ); + y[ idx ] = new Uint32Array( [ 5 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (uint32, scalar)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Uint32Array( [ 5, 5, 5, 5 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Uint32Array( [ 5, 5, 3, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Uint32Array( [ 1, 5, 5, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Uint32Array( [ 5, 2, 5, 4 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Uint32Array( [ 1, 5, 3, 5 ] ); + y[ idx ] = 5; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (complex128, array)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); + y[ idx ] = new Complex128Array( [ 9, 10 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 9, 10 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 9, 10 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 9, 10 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); + y[ idx ] = new Complex128Array( [ 9, 10 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (complex128, complex scalar)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); + y[ idx ] = new Complex128( 9, 10 ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); + y[ idx ] = new Complex128( 9, 10 ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); + y[ idx ] = new Complex128( 9, 10 ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); + y[ idx ] = new Complex128( 9, 10 ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); + y[ idx ] = new Complex128( 9, 10 ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting broadcasted integer array assignment (complex128, real scalar)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Complex128Array( [ 9, 0, 9, 0, 9, 0, 9, 0 ] ); + y[ idx ] = 9; + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Complex128Array( [ 9, 0, 9, 0, 5, 6, 7, 8 ] ); + y[ idx ] = 9; + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Complex128Array( [ 1, 2, 9, 0, 9, 0, 7, 8 ] ); + y[ idx ] = 9; + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Complex128Array( [ 9, 0, 3, 4, 9, 0, 7, 8 ] ); + y[ idx ] = 9; + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Complex128Array( [ 1, 2, 9, 0, 5, 6, 9, 0 ] ); + y[ idx ] = 9; + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting casting (generic, float64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = [ 5, 6, 7, 8 ]; + y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = [ 5, 6, 3, 4 ]; + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = [ 1, 5, 6, 4 ]; + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = [ 5, 2, 6, 4 ]; + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = [ 1, 6, 3, 5 ]; + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting casting (float64, float32)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float32Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float64Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Float32Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Int32Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Int8Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Int32Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Int8Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Int32Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Int8Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Int32Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Int8Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Int32Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Int8Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting casting (uint32, uint16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Uint32Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Uint16Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Uint32Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Uint16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Uint32Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Uint16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Uint32Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Uint16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Uint32Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Uint16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting casting (complex128, complex64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); + y[ idx ] = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); + y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); + y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); + y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); + y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float32, float64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float32Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Float32Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float32Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Float32Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float32Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); + y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); + + t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); + + x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1 ] ); + expected = new Complex64Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); + + x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Complex64Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); + + x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 2 ] ); + expected = new Complex64Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); + + x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Complex64Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); + y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); + + t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'by default, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (generic)', opts, function test( t ) { + var idx; + var x; + var y; + var i; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + for ( i = 0; i < 10; i++ ) { + idx = array2fancy.idx( [ x.length+i ] ); + t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 5; + }; + } +}); + +tape( 'by default, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (typed)', opts, function test( t ) { + var idx; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + for ( i = 0; i < 10; i++ ) { + idx = array2fancy.idx( [ x.length+i ] ); + t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 5; + }; + } +}); + +tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (generic)', opts, function test( t ) { + var idx; + var x; + var y; + var i; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x, { + 'strict': true + }); + + for ( i = 0; i < 10; i++ ) { + idx = array2fancy.idx( [ x.length+i ] ); + t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 5; + }; + } +}); + +tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (typed)', opts, function test( t ) { + var idx; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x, { + 'strict': true + }); + + for ( i = 0; i < 10; i++ ) { + idx = array2fancy.idx( [ x.length+i ] ); + t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 5; + }; + } +}); + +tape( 'when `strict` is `false`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (generic)', opts, function test( t ) { + var idx; + var x; + var y; + var i; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x, { + 'strict': false + }); + + for ( i = 0; i < 10; i++ ) { + idx = array2fancy.idx( [ x.length+i ] ); + t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 5; + }; + } +}); + +tape( 'when `strict` is `false`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (typed)', opts, function test( t ) { + var idx; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x, { + 'strict': false + }); + + for ( i = 0; i < 10; i++ ) { + idx = array2fancy.idx( [ x.length+i ] ); + t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 5; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + [], + [ 5, 6 ], + [ 5, 6, 7 ], + [ 5, 6, 7, 8, 9 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + new Int32Array( [] ), + new Int32Array( [ 5, 6 ] ), + new Int32Array( [ 5, 6, 7 ] ), + new Int32Array( [ 5, 6, 7, 8, 9 ] ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + new Complex128Array( [ 5, 6 ] ), + new Complex128( 5, 6 ), + '5', + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (complex128)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + '5', + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + new Uint32Array( [ 1 ] ), + new Uint32Array( [ 5, 6, 7, 8 ] ), + new Float64Array( [ 1 ] ), + new Float64Array( [ 5, 6, 7, 8 ] ), + new Float32Array( [ 1 ] ), + new Float32Array( [ 5, 6, 7, 8 ] ), + new Complex128Array( [ 5, 6 ] ), + 3.14, + -3.14, + new Complex128( 5, 6 ), + '5', + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = new Int8Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + new Int32Array( [ 1 ] ), + new Int32Array( [ 5, 6, 7, 8 ] ), + new Float64Array( [ 1 ] ), + new Float64Array( [ 5, 6, 7, 8 ] ), + new Float32Array( [ 1 ] ), + new Float32Array( [ 5, 6, 7, 8 ] ), + new Complex128Array( [ 5, 6 ] ), + 999999, + 3.14, + -3.14, + new Complex128( 5, 6 ), + '5', + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { + var values; + var idx; + var x; + var y; + var i; + + x = new Uint32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + + values = [ + new Int32Array( [ 1 ] ), + new Int32Array( [ 5, 6, 7, 8 ] ), + new Float64Array( [ 1 ] ), + new Float64Array( [ 5, 6, 7, 8 ] ), + new Float32Array( [ 1 ] ), + new Float32Array( [ 5, 6, 7, 8 ] ), + new Complex128Array( [ 5, 6 ] ), + -3, + 3.14, + -3.14, + new Complex128( 5, 6 ), + '5', + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + + array2fancy.idx.free( idx ); + + t.end(); + + function badValue( value ) { + return function badValue() { + y[ idx ] = value; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': false + }); + expected = [ 5, 6, 7, 8 ]; + y[ idx ] = [ 5, 6, 7, 8 ]; + + t.deepEqual( y, expected, 'returns expected value' ); + + t.throws( badValue( idx ), Error, 'throws an error' ); + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = [ 9, 10, 11, 12 ]; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': false + }); + expected = new Int32Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.throws( badValue( idx ), Error, 'throws an error' ); + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = new Int32Array( [ 9, 10, 11, 12 ] ); + }; + } +}); + +tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + expected = [ 5, 6, 7, 8 ]; + + y[ idx ] = [ 5, 6, 7, 8 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + expected = [ 9, 10, 11, 12 ]; + + y[ idx ] = [ 9, 10, 11, 12 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + array2fancy.idx.free( idx ); + + t.end(); +}); + +tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ], { + 'persist': true + }); + expected = new Int32Array( [ 5, 6, 7, 8 ] ); + + y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Int32Array( [ 9, 10, 11, 12 ] ); + + y[ idx ] = new Int32Array( [ 9, 10, 11, 12 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + array2fancy.idx.free( idx ); + + t.end(); +}); diff --git a/test/test.set.integers.js b/test/test.set.integers.js index b0cd6ac..f95fd98 100644 --- a/test/test.set.integers.js +++ b/test/test.set.integers.js @@ -30,6 +30,7 @@ var Int32Array = require( '@stdlib/array-int32' ); var Float64Array = require( '@stdlib/array-float64' ); var Complex64Array = require( '@stdlib/array-complex64' ); var Complex128Array = require( '@stdlib/array-complex128' ); +var BooleanArray = require( '@stdlib/array-bool' ); var Complex128 = require( '@stdlib/complex-float64-ctor' ); var array2fancy = require( './../lib' ); @@ -87,6 +88,25 @@ tape( 'the function returns an array-like object supporting individual element a t.end(); }); +tape( 'the function returns an array-like object supporting individual element assignment (bool, positive integer indices)', function test( t ) { + var expected; + var x; + var y; + var i; + + x = new BooleanArray( [ 0, 1, 0, 1 ] ); + y = array2fancy( x ); + + expected = new BooleanArray( [ 1, 1, 1, 1 ] ); + + for ( i = 0; i < x.length; i++ ) { + y[ i ] = true; + t.strictEqual( y[ i ], x.get( i ), 'returns expected value' ); + t.strictEqual( y[ i ], expected.get( i ), 'returns expected value' ); + } + t.end(); +}); + tape( 'the function returns an array-like object supporting individual element assignment (complex128, positive integer indices)', function test( t ) { var expected; var x; @@ -191,6 +211,27 @@ tape( 'the function returns an array-like object supporting individual element a t.end(); }); +tape( 'the function returns an array-like object supporting individual element assignment (bool, negative integer indices)', function test( t ) { + var expected; + var x; + var y; + var i; + var j; + + x = new BooleanArray( [ 0, 1, 0, 1 ] ); + y = array2fancy( x ); + + expected = new BooleanArray( [ 1, 1, 1, 1 ] ); + + for ( i = 0; i < x.length; i++ ) { + j = i - x.length; + y[ j ] = true; + t.strictEqual( y[ j ], x.get( i ), 'returns expected value' ); + t.strictEqual( y[ j ], expected.get( i ), 'returns expected value' ); + } + t.end(); +}); + tape( 'the function returns an array-like object supporting individual element assignment (complex128, negative integer indices)', function test( t ) { var expected; var x; @@ -616,3 +657,32 @@ tape( 'the function returns an array-like object which throws an error when atte }; } }); + +tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (bool)', function test( t ) { + var values; + var x; + var y; + var i; + + x = new BooleanArray( [ 0, 1, 0, 1 ] ); + y = array2fancy( x ); + + values = [ + 3.14, + -3.14, + new Complex128( 5, 6 ), + '5', + null, + 1 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ 0 ] = value; + }; + } +}); diff --git a/test/test.set.invalid.js b/test/test.set.invalid.js index 30bb099..ebb0859 100644 --- a/test/test.set.invalid.js +++ b/test/test.set.invalid.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); var Int32Array = require( '@stdlib/array-int32' ); +var Uint8Array = require( '@stdlib/array-uint8' ); var array2fancy = require( './../lib' ); @@ -152,3 +153,133 @@ tape( 'the function returns an array-like object which throws an error when prov }; } }); + +tape( 'the function returns an array-like object which throws an error when provided an invalid serialized array index (generic)', opts, function test( t ) { + var values; + var x; + var y; + var i; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x ); + + values = [ + 'ArrayIndex<9999999>', + 'ArrayIndex<9999999999>' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 0; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when provided an invalid serialized array index (typed)', opts, function test( t ) { + var values; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + values = [ + 'ArrayIndex<9999999>', + 'ArrayIndex<9999999999>' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 0; + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when provided an unsupported array index (generic)', opts, function test( t ) { + var values; + var x; + var y; + var i; + + x = [ 1, 2, 3, 4 ]; + y = array2fancy( x, { + 'cache': { + 'get': get + } + }); + + values = [ + array2fancy.idx( [ 0, 1, 2, 3 ] ), + array2fancy.idx( [ true, false, true, false ] ), + array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ) + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 0; + }; + } + + function get() { + return { + 'data': [], + 'type': 'beep', + 'dtype': 'generic' + }; + } +}); + +tape( 'the function returns an array-like object which throws an error when provided an unsupported array index (typed)', opts, function test( t ) { + var values; + var x; + var y; + var i; + + x = new Int32Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x, { + 'cache': { + 'get': get + } + }); + + values = [ + array2fancy.idx( [ 0, 1, 2, 3 ] ), + array2fancy.idx( [ true, false, true, false ] ), + array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ) + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + y[ value ] = 0; + }; + } + + function get() { + return { + 'data': [], + 'type': 'beep', + 'dtype': 'generic' + }; + } +});