From e3bf2eca0aa4a012bdf1ffb5f2e326fc416f2d20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 13 Feb 2024 03:52:39 +0000 Subject: [PATCH] Auto-generated commit --- README.md | 132 +++++++++++++++--- dist/index.js | 102 +++++++------- dist/index.js.map | 8 +- docs/repl.txt | 20 ++- examples/index.js | 26 ++++ lib/factory.js | 4 +- lib/get.js | 11 +- ..._slice_wrapper.js => get_array_wrapper.js} | 3 +- lib/get_elements.js | 63 +++++++++ lib/get_slice.js | 7 +- lib/is_array_index_string.js | 51 +++++++ lib/prop2array.js | 69 +++++++++ lib/re_array_index.js | 47 +++++++ lib/resolve_index.js | 4 +- lib/set.js | 2 + lib/set_slice.js | 1 + package.json | 4 + test/test.set.slice.js | 54 +++++++ 18 files changed, 516 insertions(+), 92 deletions(-) rename lib/{get_slice_wrapper.js => get_array_wrapper.js} (89%) create mode 100644 lib/get_elements.js create mode 100644 lib/is_array_index_string.js create mode 100644 lib/prop2array.js create mode 100644 lib/re_array_index.js diff --git a/README.md b/README.md index d9e52d1..ee3bc04 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,19 @@ v = y[ ':' ]; The function supports the following options: +- **cache**: cache for resolving array index objects. Must have a `get` method which accepts a single argument: a string identifier associated with an array index. + + If an array index associated with a provided identifier exists, the `get` method should return an object having the following properties: + + - **data**: the underlying index array. + - **type**: the index type. Must be either `'mask'`, `'bool'`, or `'int'`. + - **dtype**: the [data type][@stdlib/array/dtypes] of the underlying array. + + If an array index is not associated with a provided identifier, the `get` method should return `null`. + + Default: [`ArrayIndex`][@stdlib/array/index]. + - **strict**: boolean indicating whether to enforce strict bounds checking. Default: `false`. -- **cache**: cache for resolving array index objects. Default: [`ArrayIndex`][@stdlib/array/index]. By default, the function returns a fancy array which does **not** enforce strict bounds checking. For example, @@ -189,8 +200,19 @@ var v = y[ ':' ]; The function supports the following options: +- **cache**: default cache for resolving array index objects. Must have a `get` method which accepts a single argument: a string identifier associated with an array index. + + If an array index associated with a provided identifier exists, the `get` method should return an object having the following properties: + + - **data**: the underlying index array. + - **type**: the index type. Must be either `'mask'`, `'bool'`, or `'int'`. + - **dtype**: the [data type][@stdlib/array/dtypes] of the underlying array. + + If an array index is not associated with a provided identifier, the `get` method should return `null`. + + Default: [`ArrayIndex`][@stdlib/array/index]. + - **strict**: boolean indicating whether to enforce strict bounds checking by default. Default: `false`. -- **cache**: cache for resolving array index objects. Default: [`ArrayIndex`][@stdlib/array/index]. By default, the function returns a function which, by default, does **not** enforce strict bounds checking. For example, @@ -238,6 +260,72 @@ The returned function supports the same options as above. When the returned func - Indexing expressions provide a convenient and powerful means for creating and operating on array views; however, their use does entail a performance cost. Indexing expressions are best suited for interactive use (e.g., in the [REPL][@stdlib/repl]) and scripting. For performance critical applications, prefer equivalent functional APIs supporting array-like objects. - In older JavaScript environments which do **not** support [`Proxy`][@stdlib/proxy/ctor] objects, the use of indexing expressions is **not** supported. +### Bounds Checking + +By default, fancy arrays do **not** enforce strict bounds checking across index expressions. The motivation for the default fancy array behavior stems from a desire to maintain parity with plain arrays; namely, the returning of `undefined` when accessing a single non-existent property. + +Accordingly, when `strict` is `false`, one may observe the following behaviors: + + + +```javascript +var idx = require( '@stdlib/array-index' ); + +var x = array2fancy( [ 1, 2, 3, 4 ], { + 'strict': false +}); + +// Access a non-existent property: +var v = x[ 'foo' ]; +// returns undefined + +// Access an out-of-bounds index: +v = x[ 10 ]; +// returns undefined + +v = x[ -10 ]; +// returns undefined + +// Access an out-of-bounds slice: +v = x[ '10:' ]; +// returns [] + +// Access one or more out-of-bounds indices: +v = x[ idx( [ 10, 20 ] ) ]; +// throws +``` + +When `strict` is `true`, fancy arrays normalize index behavior and consistently enforce strict bounds checking. + + + +```javascript +var idx = require( '@stdlib/array-index' ); + +var x = array2fancy( [ 1, 2, 3, 4 ], { + 'strict': true +}); + +// Access a non-existent property: +var v = x[ 'foo' ]; +// returns undefined + +// Access an out-of-bounds index: +v = x[ 10 ]; +// throws + +v = x[ -10 ]; +// throws + +// Access an out-of-bounds slice: +v = x[ '10:' ]; +// throws + +// Access one or more out-of-bounds indices: +v = x[ idx( [ 10, 20 ] ) ]; +// throws +``` + ### Broadcasting Fancy arrays support **broadcasting** in which assigned scalars and single-element arrays are repeated (without additional memory allocation) to match the length of a target array instance. @@ -373,22 +461,6 @@ im = imag( v ); // returns 0.0 ``` -Note, however, that attempting to assign a real-valued array to a complex number array slice is **not** supported due to the ambiguity of whether the real-valued array is a collection of real components (with implied imaginary components equal to zero) or an array of interleaved real and imaginary components. - - - -```javascript -var Float64Array = require( '@stdlib/array-float64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); - -var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -var y = array2fancy( x ); - -// Attempt to assign a real-valued array: -y[ ':' ] = new Float64Array( [ 5.0, 6.0 ] ); // is this a single complex number which should be broadcast or a list of real components with implied imaginary components? -// throws -``` - @@ -404,12 +476,16 @@ y[ ':' ] = new Float64Array( [ 5.0, 6.0 ] ); // is this a single complex number ```javascript +var Uint8Array = require( '@stdlib/array-uint8' ); +var Int32Array = require( '@stdlib/array-int32' ); +var idx = require( '@stdlib/array-index' ); var array2fancy = require( '@stdlib/array-to-fancy' ); var x = [ 1, 2, 3, 4, 5, 6 ]; var y = array2fancy( x ); // returns +// Slice retrieval: var z = y[ '1::2' ]; // returns [ 2, 4, 6 ] @@ -419,6 +495,7 @@ z = y[ '-2::-2' ]; z = y[ '1:4' ]; // returns [ 2, 3, 4 ] +// Slice assignment: y[ '4:1:-1' ] = 10; z = y[ ':' ]; // returns [ 1, 2, 10, 10, 10, 6 ] @@ -426,6 +503,23 @@ z = y[ ':' ]; y[ '2:5' ] = [ -10, -9, -8 ]; z = y[ ':' ]; // returns [ 1, 2, -10, -9, -8, 6 ] + +// Array index retrieval: +var i = idx( [ 1, 3, 4 ] ); // integer index array +z = y[ i ]; +// returns [ 2, -9, -8 ] + +i = idx( [ 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 ] + +i = idx( new Int32Array( [ 0, 0, 1, 1, 2, 2 ] ) ); // integer index array +z = y[ i ]; +// returns [ 1, 1, 2, 2, -10, -10 ] ``` @@ -540,6 +634,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [@stdlib/array/index]: https://github.com/stdlib-js/array-index +[@stdlib/array/dtypes]: https://github.com/stdlib-js/array-dtypes + diff --git a/dist/index.js b/dist/index.js index c5fecb0..5f6b73a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,49 +1,57 @@ -"use strict";var u=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var S=u(function(rt,E){ -var qr=require('@stdlib/array-base-assert-is-complex-floating-point-data-type/dist'),gr=require('@stdlib/assert-is-number/dist').isPrimitive;function hr(r){return gr(r)?[r,0]:r}function mr(r){return qr(r)?hr:null}E.exports=mr -});var I=u(function(et,b){ -function wr(r,i){return a;function a(t){return r(t,i)}}b.exports=wr -});var D=u(function(tt,T){ -var Er=require('@stdlib/proxy-ctor/dist'),Sr=typeof Er=="function";T.exports=Sr -});var R=u(function(it,A){ -var br=require('@stdlib/array-index/dist');function Ir(){return{cache:br,strict:!1}}A.exports=Ir -});var P=u(function(at,k){ -var Tr=require('@stdlib/assert-is-plain-object/dist'),x=require('@stdlib/assert-has-own-property/dist'),Dr=require('@stdlib/assert-is-boolean/dist').isPrimitive,Ar=require('@stdlib/assert-is-method-in/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function Rr(r,i){return Tr(i)?x(i,"strict")&&(r.strict=i.strict,!Dr(r.strict))?new TypeError(y('1rX2o',"strict",r.strict)):x(i,"cache")&&(r.cache=i.cache,!Ar(r.cache,"get"))?new TypeError(y("invalid option. `%s` option is missing a `%s` method. Option: `%s`.","cache","get",r.cache)):null:new TypeError(y('1rX2V',i));}k.exports=Rr -});var O=u(function(nt,C){ -var l=require('@stdlib/assert-is-number/dist').isPrimitive,xr=require('@stdlib/assert-is-integer/dist').isPrimitive,f=require('@stdlib/assert-is-complex-like/dist'),kr=require('@stdlib/array-base-assert-is-real-floating-point-data-type/dist'),Pr=require('@stdlib/array-base-assert-is-unsigned-integer-data-type/dist'),_r=require('@stdlib/array-base-assert-is-signed-integer-data-type/dist'),_=require('@stdlib/array-base-assert-is-safe-data-type-cast/dist'),N=require('@stdlib/array-min-dtype/dist'),Nr=require('@stdlib/array-base-min-signed-integer-dtype/dist'),d=require('@stdlib/complex-dtype/dist'),c=require('@stdlib/error-tools-fmtprodmsg/dist');function Cr(){return null}function Or(r,i){return l(r)?null:f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function Vr(r,i){return l(r)||f(r)?null:new TypeError(c('1rXEw',typeof r,i));}function Ur(r,i){var a;return l(r)?xr(r)?(a=Nr(r),_(a,i)?null:new TypeError(c('1rXEw',a,i))):new TypeError(c('1rXEw',N(r),i)):f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function Fr(r,i){var a;return l(r)?(a=N(r),_(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 Lr(r){return r==="generic"||r===""?Cr:kr(r)?Or:Pr(r)?Fr:_r(r)?Ur:Vr}C.exports=Lr -});var U=u(function(st,V){ -function Gr(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)}}V.exports=Gr -});var L=u(function(ut,F){ -var Br=/^-?[0-9]+$/;F.exports=Br -});var q=u(function(ot,G){ -var Mr=require('@stdlib/assert-is-string/dist').isPrimitive,jr=L();function Wr(r){return Mr(r)&&jr.test(r)}G.exports=Wr -});var g=u(function(ct,B){ -var Qr=require('@stdlib/ndarray-base-normalize-index/dist'),zr=require('@stdlib/error-tools-fmtprodmsg/dist');function $r(r,i,a){var t,n;if(t=parseInt(r,10),n=Qr(t,i-1),n===-1){if(a)throw new RangeError(zr('1rXFU'));return t}return n}B.exports=$r -});var j=u(function(vt,M){ -var Hr=g();function Jr(r,i,a){return a.getter(r,Hr(i,r.length,a.strict))}M.exports=Jr -});var Q=u(function(lt,W){ -var Kr=require('@stdlib/assert-is-function/dist');function Xr(r,i,a,t){var n=r[i];if(Kr(n))return n===r.constructor?t.ctor:s;return n;function s(){var e,o;for(e=[],o=0;o1&&(s=lr(n,arguments[1]),s))throw s;return e=Ue(t),o=e.dtype||"",v={ref:t,dtype:o,getter:e.accessors[0],setter:e.accessors[1],preSetElement:Ge(o),postGetSlice:Be(a,n),cache:n.cache,strict:n.strict,validator:We(o),array2fancy:a,ctor:new vr(t.constructor||Array,{construct:Qe(a,n)})},new vr(t,{get:ze(v),set:$e(v)})}return console.warn("WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available."),t}}fr.exports=He -});var yr=u(function(St,pr){ -var Je=w(),Ke=Je();pr.exports=Ke -});var Xe=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),dr=yr(),Ye=w();Xe(dr,"factory",Ye);module.exports=dr; +"use strict";var u=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var b=u(function(It,E){ +var Ir=require('@stdlib/array-base-assert-is-complex-floating-point-data-type/dist'),Ar=require('@stdlib/assert-is-number/dist').isPrimitive;function Tr(r){return Ar(r)?[r,0]:r}function xr(r){return Ir(r)?Tr:null}E.exports=xr +});var I=u(function(At,S){ +function Rr(r,i){return a;function a(t){return r(t,i)}}S.exports=Rr +});var T=u(function(Tt,A){ +var Dr=require('@stdlib/proxy-ctor/dist'),kr=typeof Dr=="function";A.exports=kr +});var R=u(function(xt,x){ +var _r=require('@stdlib/array-index/dist');function Pr(){return{cache:_r,strict:!1}}x.exports=Pr +});var _=u(function(Rt,k){ +var Nr=require('@stdlib/assert-is-plain-object/dist'),D=require('@stdlib/assert-has-own-property/dist'),Vr=require('@stdlib/assert-is-boolean/dist').isPrimitive,Ur=require('@stdlib/assert-is-method-in/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function Cr(r,i){return Nr(i)?D(i,"strict")&&(r.strict=i.strict,!Vr(r.strict))?new TypeError(y('1rX2o',"strict",r.strict)):D(i,"cache")&&(r.cache=i.cache,!Ur(r.cache,"get"))?new TypeError(y("invalid option. `%s` option is missing a `%s` method. Option: `%s`.","cache","get",r.cache)):null:new TypeError(y('1rX2V',i));}k.exports=Cr +});var U=u(function(Dt,V){ +var l=require('@stdlib/assert-is-number/dist').isPrimitive,Or=require('@stdlib/assert-is-integer/dist').isPrimitive,f=require('@stdlib/assert-is-complex-like/dist'),Gr=require('@stdlib/array-base-assert-is-real-floating-point-data-type/dist'),Fr=require('@stdlib/array-base-assert-is-unsigned-integer-data-type/dist'),Lr=require('@stdlib/array-base-assert-is-signed-integer-data-type/dist'),P=require('@stdlib/array-base-assert-is-safe-data-type-cast/dist'),N=require('@stdlib/array-min-dtype/dist'),jr=require('@stdlib/array-base-min-signed-integer-dtype/dist'),d=require('@stdlib/complex-dtype/dist'),c=require('@stdlib/error-tools-fmtprodmsg/dist');function Br(){return null}function Mr(r,i){return l(r)?null:f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function Wr(r,i){return l(r)||f(r)?null:new TypeError(c('1rXEw',typeof r,i));}function zr(r,i){var a;return l(r)?Or(r)?(a=jr(r),P(a,i)?null:new TypeError(c('1rXEw',a,i))):new TypeError(c('1rXEw',N(r),i)):f(r)?new TypeError(c('1rXEw',d(r),i)):new TypeError(c('1rXEw',typeof r,i));}function Qr(r,i){var a;return l(r)?(a=N(r),P(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 Xr(r){return r==="generic"||r===""?Br:Gr(r)?Mr:Fr(r)?Qr:Lr(r)?zr:Wr}V.exports=Xr +});var O=u(function(kt,C){ +function Yr(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)}}C.exports=Yr +});var F=u(function(_t,G){ +var $r=/^-?[0-9]+$/;G.exports=$r +});var q=u(function(Pt,L){ +var Hr=require('@stdlib/assert-is-string/dist').isPrimitive,Jr=F();function Kr(r){return Hr(r)&&Jr.test(r)}L.exports=Kr +});var B=u(function(Nt,j){ +var Zr=/\s*ArrayIndex<[^>]+>\s*/;j.exports=Zr +});var W=u(function(Vt,M){ +var re=require('@stdlib/assert-is-string/dist').isPrimitive,ee=B();function te(r){return re(r)&&ee.test(r)}M.exports=te +});var Q=u(function(Ut,z){ +var ie=require('@stdlib/string-base-trim/dist'),ae=require('@stdlib/error-tools-fmtprodmsg/dist');function ne(r){return r.substring(11,r.length-1)}function se(r,i){var a=i.get(ne(ie(r)));if(a===null)throw new Error(ae("invalid operation. Unable to resolve array index. Value: `%s`.",r));return a}z.exports=se +});var Y=u(function(Ct,X){ +var ue=require('@stdlib/array-take/dist'),oe=require('@stdlib/array-base-mskfilter/dist'),ce=require('@stdlib/array-base-mskreject/dist'),ve=require('@stdlib/error-tools-fmtprodmsg/dist'),le=Q();function fe(r,i,a){var t=le(i,a.cache);if(t.type==="int")return a.postGetArray(ue(r,t.data));if(t.type==="bool")return a.postGetArray(oe(r,t.data));if(t.type==="mask")return a.postGetArray(ce(r,t.data));throw new Error(ve("invalid operation. Unrecognized array index type. Value: `%s`.",t.type))}X.exports=fe +});var g=u(function(Ot,$){ +var pe=require('@stdlib/ndarray-base-normalize-index/dist'),ye=require('@stdlib/error-tools-fmtprodmsg/dist');function de(r,i,a){var t,n;if(t=parseInt(r,10),n=pe(t,i-1),n===-1){if(a)throw new RangeError(ye("invalid operation. Index exceeds array bounds."));return t}return n}$.exports=de +});var J=u(function(Gt,H){ +var qe=g();function ge(r,i,a){return a.getter(r,qe(i,r.length,a.strict))}H.exports=ge +});var Z=u(function(Ft,K){ +var me=require('@stdlib/assert-is-function/dist');function he(r,i,a,t){var n=r[i];if(me(n))return n===r.constructor?t.ctor:s;return n;function s(){var e,o;for(e=[],o=0;o1&&(s=hr(n,arguments[1]),s))throw s;return e=ut(t),o=e.dtype||"",v={ref:t,dtype:o,getter:e.accessors[0],setter:e.accessors[1],preSetElement:vt(o),postGetArray:lt(a,n),cache:n.cache,strict:n.strict,validator:yt(o),array2fancy:a,ctor:new mr(t.constructor||Array,{construct:dt(a,n)})},new mr(t,{get:qt(v),set:gt(v)})}return console.warn("WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available."),t}}wr.exports=mt +});var br=u(function(Ht,Er){ +var ht=w(),wt=ht();Er.exports=wt +});var Et=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),Sr=br(),bt=w();Et(Sr,"factory",bt);module.exports=Sr; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map index 1392d70..0b55f73 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_slice_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/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 slices 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* @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' );\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' );\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// 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} slice 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. Slice 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 argument/, '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} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {Function} ctx.postGetSlice - function to process a retrieved slice\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, receiver, 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.postGetSlice( 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 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.postGetSlice - function to process a retrieved slice\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* @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\treturn getSlice( target, property, receiver, 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 {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* @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 getSliceWrapper = require( './get_slice_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'postGetSlice': getSliceWrapper( 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 main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\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,cA+BA,SAASC,GAASC,EAAaC,EAAO,CACrC,OAAOC,EASP,SAASA,EAAMC,EAAI,CAClB,OAAOH,EAAaG,EAAGF,CAAK,CAC7B,CACD,CAKAH,EAAO,QAAUC,KCjDjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAQ,QAAS,oBAAqB,EAYtCC,GAAe,OAAOD,IAAU,WAKpCD,EAAO,QAAUE,KCvCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAA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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,GAAO,KACPC,GAAU,IAKdF,GAAaC,GAAM,UAAWC,EAAQ,EAKtC,OAAO,QAAUD", - "names": ["require_set_element_wrapper", "__commonJSMin", "exports", "module", "isComplexDataType", "isNumber", "wrapComplex", "value", "wrapper", "dtype", "require_get_slice_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_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", "receiver", "ctx", "s", "err", "require_get", "__commonJSMin", "exports", "module", "isString", "hasProperty", "isIntegerString", "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", "getSliceWrapper", "hasProxySupport", "defaults", "validate", "validator", "ctor", "get", "set", "factory", "OPTIONS", "err", "array2fancy", "x", "opts", "arr", "dt", "o", "require_main", "__commonJSMin", "exports", "module", "factory", "array2fancy", "setReadOnly", "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_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' );\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' );\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-base-mskfilter' );\nvar mskreject = require( '@stdlib/array-base-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 argument/, '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 main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\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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C,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,GAAO,KACPC,GAAU,IAKdF,GAAaC,GAAM,UAAWC,EAAQ,EAKtC,OAAO,QAAUD", + "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", "main", "factory"] } diff --git a/docs/repl.txt b/docs/repl.txt index 1481081..09ea891 100644 --- a/docs/repl.txt +++ b/docs/repl.txt @@ -48,12 +48,6 @@ scalar to a complex number argument having an imaginary component equal to zero. - Note, however, that attempting to assign a real-valued array to a complex - number array slice is *not* supported due to the ambiguity of whether the - real-valued array is a collection of real components (with implied imaginary - components equal to zero) or an array of interleaved real and imaginary - components. - In older JavaScript environments which do not support Proxy objects, the use of indexing expressions is not supported. @@ -71,9 +65,10 @@ options.cache: Object (optional) Cache for resolving array index objects. Must have a 'get' method which - accepts a single argument: an identifier associated with an array index. - If an array index associated with a provided identifier exists, the - 'get' method should return an object having the following properties: + accepts a single argument: a string identifier associated with an array + index. If an array index associated with a provided identifier exists, + the 'get' method should return an object having the following + properties: - data: the underlying index array. - type: the index type. Must be either 'mask', 'bool', or 'int'. @@ -111,9 +106,10 @@ options.cache: Object (optional) Cache for resolving array index objects. Must have a 'get' method which - accepts a single argument: an identifier associated with an array index. - If an array index associated with a provided identifier exists, the - 'get' method should return an object having the following properties: + accepts a single argument: a string identifier associated with an array + index. If an array index associated with a provided identifier exists, + the 'get' method should return an object having the following + properties: - data: the underlying index array. - type: the index type. Must be either 'mask', 'bool', or 'int'. diff --git a/examples/index.js b/examples/index.js index 7c5a1fd..d0b8f7c 100644 --- a/examples/index.js +++ b/examples/index.js @@ -18,12 +18,16 @@ 'use strict'; +var Uint8Array = require( '@stdlib/array-uint8' ); +var Int32Array = require( '@stdlib/array-int32' ); +var idx = require( '@stdlib/array-index' ); var array2fancy = require( './../lib' ); var x = [ 1, 2, 3, 4, 5, 6 ]; var y = array2fancy( x ); // returns +// Slice retrieval: var z = y[ '1::2' ]; console.log( z ); // => [ 2, 4, 6 ] @@ -36,6 +40,7 @@ z = y[ '1:4' ]; console.log( z ); // => [ 2, 3, 4 ] +// Slice assignment: y[ '4:1:-1' ] = 10; z = y[ ':' ]; console.log( z ); @@ -45,3 +50,24 @@ y[ '2:5' ] = [ -10, -9, -8 ]; z = y[ ':' ]; console.log( z ); // => [ 1, 2, -10, -9, -8, 6 ] + +// Array index retrieval: +var i = idx( [ 1, 3, 4 ] ); // integer index array +z = y[ i ]; +console.log( z ); +// => [ 2, -9, -8 ] + +i = idx( [ 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 ); +// => [ 1, 2, -9, -8 ] + +i = idx( new Int32Array( [ 0, 0, 1, 1, 2, 2 ] ) ); // integer index array +z = y[ i ]; +console.log( z ); +// => [ 1, 1, 2, 2, -10, -10 ] diff --git a/lib/factory.js b/lib/factory.js index e6d7cb8..8b4c667 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -26,7 +26,7 @@ var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); var assign = require( '@stdlib/object-assign' ); var format = require( '@stdlib/string-format' ); var setElementWrapper = require( './set_element_wrapper.js' ); -var getSliceWrapper = require( './get_slice_wrapper.js' ); +var getArrayWrapper = require( './get_array_wrapper.js' ); var hasProxySupport = require( './has_proxy_support.js' ); var defaults = require( './defaults.js' ); var validate = require( './validate.js' ); @@ -143,7 +143,7 @@ function factory() { 'getter': arr.accessors[ 0 ], 'setter': arr.accessors[ 1 ], 'preSetElement': setElementWrapper( dt ), - 'postGetSlice': getSliceWrapper( array2fancy, opts ), + 'postGetArray': getArrayWrapper( array2fancy, opts ), 'cache': opts.cache, 'strict': opts.strict, 'validator': validator( dt ), diff --git a/lib/get.js b/lib/get.js index 999dc34..a7be26a 100644 --- a/lib/get.js +++ b/lib/get.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 getElements = require( './get_elements.js' ); var getElement = require( './get_element.js' ); var getValue = require( './get_value.js' ); var getSlice = require( './get_slice.js' ); @@ -38,7 +40,8 @@ var getSlice = require( './get_slice.js' ); * @param {Function} ctx.getter - accessor for retrieving array elements * @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking * @param {Function} ctx.ctor - proxied array constructor -* @param {Function} ctx.postGetSlice - function to process a retrieved slice +* @param {Function} ctx.postGetArray - function to process a retrieved array +* @param {Object} ctx.cache - cache for resolving array index objects * @returns {Function} handler */ function factory( ctx ) { @@ -53,6 +56,7 @@ function factory( ctx ) { * @param {Object} receiver - the proxy object or an object inheriting from the proxy * @throws {Error} invalid slice operation * @throws {RangeError} slice exceeds array bounds + * @throws {RangeError} index exceeds array bounds * @returns {*} result */ function get( target, property, receiver ) { @@ -62,7 +66,10 @@ function factory( ctx ) { if ( hasProperty( target, property ) || !isString( property ) ) { return getValue( target, property, receiver, ctx ); } - return getSlice( target, property, receiver, ctx ); + if ( isArrayIndexString( property ) ) { + return getElements( target, property, ctx ); + } + return getSlice( target, property, ctx ); } } diff --git a/lib/get_slice_wrapper.js b/lib/get_array_wrapper.js similarity index 89% rename from lib/get_slice_wrapper.js rename to lib/get_array_wrapper.js index 7909762..32ee7e7 100644 --- a/lib/get_slice_wrapper.js +++ b/lib/get_array_wrapper.js @@ -21,12 +21,13 @@ // MAIN // /** -* Returns a wrapper function for processing slices after retrieval. +* Returns a wrapper function for processing arrays after retrieval. * * @private * @param {Function} array2fancy - function for creating a proxied array * @param {Object} opts - options * @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking +* @param {Function} opts.cache - cache for resolving array index objects * @returns {Function} wrapper function */ function wrapper( array2fancy, opts ) { diff --git a/lib/get_elements.js b/lib/get_elements.js new file mode 100644 index 0000000..3d436c3 --- /dev/null +++ b/lib/get_elements.js @@ -0,0 +1,63 @@ +/** +* @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 take = require( '@stdlib/array-take' ); +var mskfilter = require( '@stdlib/array-base-mskfilter' ); +var mskreject = require( '@stdlib/array-base-mskreject' ); +var format = require( '@stdlib/string-format' ); +var prop2array = require( './prop2array.js' ); + + +// MAIN // + +/** +* Returns the elements specified by an array index. +* +* @private +* @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 +* @throws {RangeError} index exceeds array bounds +* @returns {Collection} result +*/ +function getElements( target, property, ctx ) { + var idx = prop2array( property, ctx.cache ); + if ( idx.type === 'int' ) { + return ctx.postGetArray( take( target, idx.data ) ); + } + if ( idx.type === 'bool' ) { + return ctx.postGetArray( mskfilter( target, idx.data ) ); + } + if ( idx.type === 'mask' ) { + return ctx.postGetArray( mskreject( target, idx.data ) ); + } + throw new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) ); +} + + +// EXPORTS // + +module.exports = getElements; diff --git a/lib/get_slice.js b/lib/get_slice.js index e87a949..fcf858d 100644 --- a/lib/get_slice.js +++ b/lib/get_slice.js @@ -33,22 +33,21 @@ var prop2slice = require( './prop2slice.js' ); * @private * @param {Object} target - target object * @param {string} property - property name -* @param {Object} receiver - the proxy object or an object inheriting from the proxy * @param {Object} ctx - context object -* @param {Function} ctx.postGetSlice - function to process a retrieved slice +* @param {Function} ctx.postGetArray - function to process a retrieved array * @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking * @throws {Error} invalid slice operation * @throws {RangeError} slice exceeds array bounds * @returns {(Collection|void)} result */ -function getSlice( target, property, receiver, ctx ) { +function getSlice( target, property, ctx ) { var s = prop2slice( target, property, ctx.strict ); if ( s === null ) { // Ensure consistency with normal array behavior by returning `undefined` for any "unrecognized" property name: return; } try { - return ctx.postGetSlice( slice( target, s, ctx.strict ) ); + return ctx.postGetArray( slice( target, s, ctx.strict ) ); } catch ( err ) { // In principle, we should only error when in "strict" mode and a slice exceeds array bounds... throw new err.constructor( errMessage( err.message ) ); diff --git a/lib/is_array_index_string.js b/lib/is_array_index_string.js new file mode 100644 index 0000000..5aaae57 --- /dev/null +++ b/lib/is_array_index_string.js @@ -0,0 +1,51 @@ +/** +* @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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; +var RE_ARRAY_INDEX = require( './re_array_index.js' ); + + +// MAIN // + +/** +* Tests if an indexing expression is a serialized array index. +* +* @private +* @param {(string|symbol)} prop - property name +* @returns {boolean} result +* +* @example +* var out = isArrayIndexString( 'ArrayIndex<0>' ); +* // returns true +* +* @example +* var out = isArrayIndexString( ':' ); +* // returns false +*/ +function isArrayIndexString( prop ) { + return ( isString( prop ) && RE_ARRAY_INDEX.test( prop ) ); +} + + +// EXPORTS // + +module.exports = isArrayIndexString; diff --git a/lib/prop2array.js b/lib/prop2array.js new file mode 100644 index 0000000..6442ea7 --- /dev/null +++ b/lib/prop2array.js @@ -0,0 +1,69 @@ +/** +* @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 trim = require( '@stdlib/string-base-trim' ); +var format = require( '@stdlib/string-format' ); + + +// FUNCTIONS // + +/** +* Extracts an array index identifier from an array index indexing expression. +* +* @private +* @param {string} str - input string +* @returns {string} identifier +* +* @example +* var str = 'ArrayIndex<0>'; +* +* var id = getIdentifier( str ); +* // returns '0' +*/ +function getIdentifier( str ) { + return str.substring( 11, str.length-1 ); // ArrayIndex => XX +} + + +// MAIN // + +/** +* Converts an indexing expression to an array index. +* +* @private +* @param {string} property - property name +* @param {Object} cache - cache for resolving array index objects +* @throws {Error} invalid array index +* @returns {(Object|null)} index object (or null) +*/ +function prop2array( property, cache ) { + var o = cache.get( getIdentifier( trim( property ) ) ); + if ( o === null ) { + throw new Error( format( 'invalid operation. Unable to resolve array index. Value: `%s`.', property ) ); + } + return o; +} + + +// EXPORTS // + +module.exports = prop2array; diff --git a/lib/re_array_index.js b/lib/re_array_index.js new file mode 100644 index 0000000..10046ea --- /dev/null +++ b/lib/re_array_index.js @@ -0,0 +1,47 @@ +/** +* @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'; + +// MAIN // + +/** +* Regular expression for testing whether a string is a serialized array index. +* +* @private +* @name RE_ARRAY_INDEX +* @type {RegExp} +* +* @example +* var bool = RE_ARRAY_INDEX.test( 'ArrayIndex<0>' ); +* // returns true +* +* @example +* var bool = RE_ARRAY_INDEX.test( '0' ); +* // returns false +* +* @example +* var bool = RE_ARRAY_INDEX.test( 'Slice(0,10,2)' ); +* // returns false +*/ +var RE_ARRAY_INDEX = /\s*ArrayIndex<[^>]+>\s*/; + + +// EXPORTS // + +module.exports = RE_ARRAY_INDEX; diff --git a/lib/resolve_index.js b/lib/resolve_index.js index cb56223..0b5de40 100644 --- a/lib/resolve_index.js +++ b/lib/resolve_index.js @@ -33,7 +33,7 @@ var format = require( '@stdlib/string-format' ); * @param {string} str - integer string * @param {NonNegativeInteger} max - index upper bound (exclusive) * @param {boolean} strict - boolean indicating whether to enforce strict bounds checking -* @throws {RangeError} slice exceeds array bounds +* @throws {RangeError} index exceeds array bounds * @returns {integer} integer index * * @example @@ -52,7 +52,7 @@ function resolveIndex( str, max, strict ) { i = normalizeIndex( idx, max-1 ); if ( i === -1 ) { if ( strict ) { - throw new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) ); + throw new RangeError( format( 'invalid operation. Index exceeds array bounds.' ) ); } // Return the non-normalized index, as this should fallback to default property handling and returning "undefined": return idx; diff --git a/lib/set.js b/lib/set.js index a40d210..c2186ef 100644 --- a/lib/set.js +++ b/lib/set.js @@ -57,6 +57,8 @@ function factory( ctx ) { * @throws {Error} invalid slice operation * @throws {Error} assigned value must be broadcast compatible with output array view * @throws {TypeError} assigned value cannot be safely cast to the output array data type + * @throws {TypeError} slice exceeds array bounds + * @throws {TypeError} index exceeds array bounds * @returns {boolean} boolean indicating whether assignment succeeded */ function set( target, property, value, receiver ) { diff --git a/lib/set_slice.js b/lib/set_slice.js index feaed8a..d0e7610 100644 --- a/lib/set_slice.js +++ b/lib/set_slice.js @@ -41,6 +41,7 @@ var errMessage = require( './error_message.js' ); * @param {string} ctx.dtype - array data type * @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking * @throws {Error} invalid slice operation +* @throws {RangeError} slice exceeds array bounds * @throws {Error} assigned value must be broadcast compatible with target array view * @throws {TypeError} assigned value cannot be safely cast to the target array data type * @throws {TypeError} target array must have a supported data type diff --git a/package.json b/package.json index 4ff1002..6c1cfc7 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,12 @@ "@stdlib/array-base-fancy-slice": "^0.2.0", "@stdlib/array-base-fancy-slice-assign": "^0.1.0", "@stdlib/array-base-min-signed-integer-dtype": "^0.1.0", + "@stdlib/array-base-mskfilter": "^0.1.0", + "@stdlib/array-base-mskreject": "^0.1.0", "@stdlib/array-from-scalar": "^0.1.0", "@stdlib/array-index": "github:stdlib-js/array-index#main", "@stdlib/array-min-dtype": "^0.1.0", + "@stdlib/array-take": "github:stdlib-js/array-take#main", "@stdlib/assert-has-own-property": "^0.1.1", "@stdlib/assert-has-property": "^0.1.1", "@stdlib/assert-is-array-like": "^0.1.0", @@ -84,6 +87,7 @@ "@stdlib/array-int8": "^0.1.1", "@stdlib/array-uint16": "^0.1.1", "@stdlib/array-uint32": "^0.1.1", + "@stdlib/array-uint8": "^0.1.1", "@stdlib/array-zero-to": "^0.1.0", "@stdlib/assert-has-proxy-support": "^0.1.1", "@stdlib/assert-has-symbol-support": "^0.1.1", diff --git a/test/test.set.slice.js b/test/test.set.slice.js index 510b5e0..8d0c056 100644 --- a/test/test.set.slice.js +++ b/test/test.set.slice.js @@ -1241,6 +1241,60 @@ tape( 'the function returns an array-like object supporting casting (complex128, t.end(); }); +tape( 'the function returns an array-like object supporting casting (complex128, float64)', opts, function test( t ) { + var expected; + var x; + var y; + var s; + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + s = new Slice(); + expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); + y[ s ] = new Float64Array( [ 9, 10, 11, 12 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + s = new Slice( 2 ); + expected = new Complex128Array( [ 17, 0, 18, 0, 5, 6, 7, 8 ] ); + y[ s ] = new Float64Array( [ 17, 18 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + s = new Slice( 1, 3 ); + expected = new Complex128Array( [ 1, 2, 17, 0, 18, 0, 7, 8 ] ); + y[ s ] = new Float64Array( [ 17, 18 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + s = new Slice( null, null, 2 ); + expected = new Complex128Array( [ 17, 0, 3, 4, 18, 0, 7, 8 ] ); + y[ s ] = new Float64Array( [ 17, 18 ] ); + + t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + y = array2fancy( x ); + + s = new Slice( -1, null, -2 ); + expected = new Complex128Array( [ 1, 2, 18, 0, 5, 6, 17, 0 ] ); + y[ s ] = new Float64Array( [ 17, 18 ] ); + + 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 x;