@stdlib/array-index 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -420,6 +420,7 @@ var o = idx.toJSON();
420
420
  ```javascript
421
421
  var Uint8Array = require( '@stdlib/array-uint8' );
422
422
  var Int32Array = require( '@stdlib/array-int32' );
423
+ var BooleanArray = require( '@stdlib/array-bool' );
423
424
  var ArrayIndex = require( '@stdlib/array-index' );
424
425
 
425
426
  var x = new Uint8Array( [ 1, 0, 1, 0 ] );
@@ -440,6 +441,15 @@ o = ArrayIndex.get( i.id );
440
441
 
441
442
  console.log( 'Type: %s. Data type: %s.', o.type, o.dtype );
442
443
 
444
+ x = new BooleanArray( [ true, false, true, false ] );
445
+ i = new ArrayIndex( x );
446
+ // returns <ArrayIndex>
447
+
448
+ o = ArrayIndex.get( i.id );
449
+ // returns {...}
450
+
451
+ console.log( 'Type: %s. Data type: %s.', o.type, o.dtype );
452
+
443
453
  x = new Int32Array( [ 1, 3, 4, 7 ] );
444
454
  i = new ArrayIndex( x );
445
455
  // returns <ArrayIndex>
@@ -524,8 +534,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
524
534
  [npm-image]: http://img.shields.io/npm/v/@stdlib/array-index.svg
525
535
  [npm-url]: https://npmjs.org/package/@stdlib/array-index
526
536
 
527
- [test-image]: https://github.com/stdlib-js/array-index/actions/workflows/test.yml/badge.svg?branch=v0.2.1
528
- [test-url]: https://github.com/stdlib-js/array-index/actions/workflows/test.yml?query=branch:v0.2.1
537
+ [test-image]: https://github.com/stdlib-js/array-index/actions/workflows/test.yml/badge.svg?branch=v0.3.0
538
+ [test-url]: https://github.com/stdlib-js/array-index/actions/workflows/test.yml?query=branch:v0.3.0
529
539
 
530
540
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-index/main.svg
531
541
  [coverage-url]: https://codecov.io/github/stdlib-js/array-index?branch=main
package/dist/index.js CHANGED
@@ -1,15 +1,19 @@
1
- "use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var c=u(function(Z,p){
2
- function A(){return{persist:!1}}p.exports=A
3
- });var g=u(function($,h){
4
- var I=require('@stdlib/assert-is-plain-object/dist'),S=require('@stdlib/assert-has-own-property/dist'),j=require('@stdlib/assert-is-boolean/dist').isPrimitive,y=require('@stdlib/error-tools-fmtprodmsg/dist');function N(r,e){return I(e)?S(e,"persist")&&(r.persist=e.persist,!j(r.persist))?new TypeError(y('1rz2o',"persist",r.persist)):null:new TypeError(y('1rz2V',e));}h.exports=N
5
- });var v=u(function(ee,m){
6
- var P=require('@stdlib/utils-linked-list/dist'),k=new P;m.exports=k
7
- });var q=u(function(re,w){
8
- var C=v();function F(r){for(var e=C.first();e;){if(e.value.id===r)return e;e=e.next}return null}w.exports=F
9
- });var x=u(function(te,_){
10
- var b=-1;function R(){return b+=1,b.toString()}_.exports=R
11
- });var O=u(function(ae,T){
12
- var d=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),B=require('@stdlib/utils-define-nonenumerable-property/dist'),J=require('@stdlib/assert-is-collection/dist'),L=require('@stdlib/assert-is-boolean/dist').isPrimitive,V=require('@stdlib/assert-is-integer/dist').isPrimitive,G=require('@stdlib/array-base-assert-is-accessor-array/dist'),U=require('@stdlib/array-to-json/dist'),z=require('@stdlib/array-dtype/dist'),D=require('@stdlib/array-base-copy/dist'),H=require('@stdlib/array-base-resolve-getter/dist'),K=require('@stdlib/error-tools-fmtprodmsg/dist'),M=c(),Q=g(),f=v(),E=q(),W=x();function a(r){var e,t,n,i,o,l;if(!(this instanceof a))return arguments.length>1?new a(r,arguments[1]):new a(r);if(!J(r))throw new TypeError(K('1rz2O',r));if(i=z(r),i==="generic"||i===null)if(r.length>0)if(n=H(r),l=n(r,0),L(l))o="bool";else if(V(l))o="int";else throw new TypeError(K('1rzFV'));else o="int";else if(i==="int32")o="int";else if(i==="uint8")o="mask";else throw new TypeError(K('1rzFV'));if(e=M(),arguments.length>1&&(t=Q(e,arguments[1]),t))throw t;return f.push({id:W(),ref:this,data:r,type:o,dtype:i,persist:e.persist}),s(this,"_node",f.last()),B(this,"_invalidated",!1),this}s(a,"name","ArrayIndex");s(a,"free",function(e){var t,n;return t=E(e),t===null?!1:(n=t.value,s(n.ref,"_invalidated",!0),f.remove(t),n.data=null,!0)});s(a,"get",function(e){var t,n,i;return t=E(e),t===null?null:(i=t.value,n={data:i.data,type:i.type,dtype:i.dtype},i.persist||a.free(e),n)});d(a.prototype,"data",function(){if(this._invalidated)throw new Error(K('1rzFW'));return this._node.value.data});d(a.prototype,"dtype",function(){if(this._invalidated)throw new Error(K('1rzFW'));return this._node.value.dtype});d(a.prototype,"id",function(){if(this._invalidated)throw new Error(K('1rzFW'));return this._node.value.id});d(a.prototype,"isCached",function(){return!this._invalidated});d(a.prototype,"type",function(){if(this._invalidated)throw new Error(K('1rzFW'));return this._node.value.type});s(a.prototype,"toString",function(){var e;if(this._invalidated)throw new Error(K('1rzFW'));return e=this._node.value,"ArrayIndex<"+e.id+">"});s(a.prototype,"toJSON",function(){var e,t;if(this._invalidated)throw new Error(K('1rzFW'));return e=this._node.value,e.dtype==="generic"||e.dtype===null?G(e.data)?t=D(e.data):t=e.data:t=U(e.data),{type:"ArrayIndex",data:t}});T.exports=a
13
- });var X=O();module.exports=X;
14
- /** @license Apache-2.0 */
1
+ "use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var c=u(function(Z,p){"use strict";function A(){return{persist:!1}}p.exports=A});var g=u(function($,h){"use strict";var I=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),j=require("@stdlib/assert-is-boolean").isPrimitive,y=require("@stdlib/string-format");function N(r,e){return I(e)?S(e,"persist")&&(r.persist=e.persist,!j(r.persist))?new TypeError(y("invalid option. `%s` option must be a boolean. Option: `%s`.","persist",r.persist)):null:new TypeError(y("invalid argument. Options argument must be an object. Value: `%s`.",e))}h.exports=N});var v=u(function(ee,m){"use strict";var P=require("@stdlib/utils-linked-list"),k=new P;m.exports=k});var b=u(function(re,w){"use strict";var C=v();function F(r){for(var e=C.first();e;){if(e.value.id===r)return e;e=e.next}return null}w.exports=F});var x=u(function(te,_){"use strict";var q=-1;function R(){return q+=1,q.toString()}_.exports=R});var O=u(function(ae,T){"use strict";var d=require("@stdlib/utils-define-nonenumerable-read-only-accessor"),o=require("@stdlib/utils-define-nonenumerable-read-only-property"),B=require("@stdlib/utils-define-nonenumerable-property"),J=require("@stdlib/assert-is-collection"),L=require("@stdlib/assert-is-boolean").isPrimitive,V=require("@stdlib/assert-is-integer").isPrimitive,G=require("@stdlib/array-base-assert-is-accessor-array"),U=require("@stdlib/array-to-json"),z=require("@stdlib/array-dtype"),D=require("@stdlib/array-base-copy"),H=require("@stdlib/array-base-resolve-getter"),K=require("@stdlib/string-format"),M=c(),Q=g(),f=v(),E=b(),W=x();function a(r){var e,t,n,i,s,l;if(!(this instanceof a))return arguments.length>1?new a(r,arguments[1]):new a(r);if(!J(r))throw new TypeError(K("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(i=z(r),i==="generic"||i===null)if(r.length>0)if(n=H(r),l=n(r,0),L(l))s="bool";else if(V(l))s="int";else throw new TypeError("invalid argument. First argument must be a valid index array.");else s="int";else if(i==="int32")s="int";else if(i==="uint8")s="mask";else if(i==="bool")s="bool";else throw new TypeError("invalid argument. First argument must be a valid index array.");if(e=M(),arguments.length>1&&(t=Q(e,arguments[1]),t))throw t;return f.push({id:W(),ref:this,data:r,type:s,dtype:i,persist:e.persist}),o(this,"_node",f.last()),B(this,"_invalidated",!1),this}o(a,"name","ArrayIndex");o(a,"free",function(e){var t,n;return t=E(e),t===null?!1:(n=t.value,o(n.ref,"_invalidated",!0),f.remove(t),n.data=null,!0)});o(a,"get",function(e){var t,n,i;return t=E(e),t===null?null:(i=t.value,n={data:i.data,type:i.type,dtype:i.dtype},i.persist||a.free(e),n)});d(a.prototype,"data",function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.data});d(a.prototype,"dtype",function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.dtype});d(a.prototype,"id",function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.id});d(a.prototype,"isCached",function(){return!this._invalidated});d(a.prototype,"type",function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.type});o(a.prototype,"toString",function(){var e;if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return e=this._node.value,"ArrayIndex<"+e.id+">"});o(a.prototype,"toJSON",function(){var e,t;if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return e=this._node.value,e.dtype==="generic"||e.dtype===null?G(e.data)?t=D(e.data):t=e.data:t=U(e.data),{type:"ArrayIndex",data:t}});T.exports=a});var X=O();module.exports=X;
2
+ /**
3
+ * @license Apache-2.0
4
+ *
5
+ * Copyright (c) 2024 The Stdlib Authors.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
15
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/defaults.js", "../lib/validate.js", "../lib/cache.js", "../lib/find.js", "../lib/id.js", "../lib/main.js", "../lib/index.js"],
4
- "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// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} defaults\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'persist': 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 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.persist] - boolean indicating whether to continue persisting an index object after first usage\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'persist': 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, 'persist' ) ) {\n\t\topts.persist = options.persist;\n\t\tif ( !isBoolean( opts.persist ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'persist', opts.persist ) );\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 LinkedList = require( '@stdlib/utils-linked-list' );\n\n\n// MAIN //\n\n/**\n* Cache for storing index arrays.\n*\n* @private\n* @name cache\n* @type {LinkedList}\n*/\nvar cache = new LinkedList(); // note: created as a linked list to allow for more efficient removal of expired index arrays\n\n\n// EXPORTS //\n\nmodule.exports = cache;\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 cache = require( './cache.js' );\n\n\n// MAIN //\n\n/**\n* Returns an array index object associated with a specified identifier.\n*\n* @private\n* @param {*} id - identifier\n* @returns {(Node|null)} array index object\n*/\nfunction find( id ) { // eslint-disable-line stdlib/no-redeclare\n\tvar node = cache.first();\n\twhile ( node ) {\n\t\tif ( node.value.id === id ) {\n\t\t\treturn node;\n\t\t}\n\t\tnode = node.next;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = find;\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// VARIABLES //\n\nvar COUNTER = -1; // TODO: consider another approach for unique identifier generation. For most cases, this should suffice; however, it is possible that two different libraries, both relying on separate copies of this package, may trigger id collisions in the event that instantiated instances were to interact (e.g., a consumer attempting to free an instance instantiated by another copy of the package, etc).\n\n\n// MAIN //\n\n/**\n* Generates a new identifier.\n*\n* @private\n* @returns {string} identifier\n*\n* @example\n* var v = id();\n* // returns <string>\n*/\nfunction id() {\n\tCOUNTER += 1;\n\treturn COUNTER.toString();\n}\n\n\n// EXPORTS //\n\nmodule.exports = id;\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/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar array2json = require( '@stdlib/array-to-json' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar copy = require( '@stdlib/array-base-copy' );\nvar resolveGetter = require( '@stdlib/array-base-resolve-getter' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.js' );\nvar validate = require( './validate.js' );\nvar cache = require( './cache.js' );\nvar findArrayIndex = require( './find.js' );\nvar generateId = require( './id.js' );\n\n\n// MAIN //\n\n/**\n* Array index constructor.\n*\n* @param {Collection} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.persist=false] - boolean indicating whether to continue persisting an index object after first usage\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} first argument must be a valid index array\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayIndex} ArrayIndex instance\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var x = new Uint8Array( [ 1, 0, 1, 0 ] );\n*\n* var idx = new ArrayIndex( x );\n* // returns <ArrayIndex>\n*/\nfunction ArrayIndex( x ) {\n\tvar opts;\n\tvar err;\n\tvar get;\n\tvar dt;\n\tvar t;\n\tvar v;\n\tif ( !(this instanceof ArrayIndex) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new ArrayIndex( x, arguments[ 1 ] );\n\t\t}\n\t\treturn new ArrayIndex( x );\n\t}\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tdt = dtype( x );\n\n\t// When provided a \"generic\" array or an array of an unknown data type, attempt to infer the type of index array...\n\tif ( dt === 'generic' || dt === null ) {\n\t\tif ( x.length > 0 ) {\n\t\t\tget = resolveGetter( x );\n\t\t\tv = get( x, 0 );\n\n\t\t\t// Infer the \"type\" of index array from the first element...\n\t\t\tif ( isBoolean( v ) ) {\n\t\t\t\tt = 'bool';\n\t\t\t} else if ( isInteger( v ) ) {\n\t\t\t\tt = 'int';\n\t\t\t} else {\n\t\t\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t\t\t}\n\t\t} else {\n\t\t\tt = 'int';\n\t\t}\n\t} else if ( dt === 'int32' ) {\n\t\tt = 'int';\n\t} else if ( dt === 'uint8' ) {\n\t\tt = 'mask';\n\t} else {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t}\n\t// Resolve index options:\n\topts = defaults();\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, arguments[ 1 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Add the array index to the index cache:\n\tcache.push({\n\t\t'id': generateId(),\n\t\t'ref': this,\n\t\t'data': x,\n\t\t'type': t,\n\t\t'dtype': dt,\n\t\t'persist': opts.persist\n\t});\n\n\t// Store a reference to the cache node:\n\tsetReadOnly( this, '_node', cache.last() );\n\n\t// Initialize a boolean flag indicating whether an array index object has been invalidated (i.e., freed):\n\tsetNonEnumerable( this, '_invalidated', false );\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ArrayIndex\n* @readonly\n* @type {string}\n* @default 'ArrayIndex'\n*\n* @example\n* var str = ArrayIndex.name;\n* // returns 'ArrayIndex'\n*/\nsetReadOnly( ArrayIndex, 'name', 'ArrayIndex' );\n\n/**\n* Frees an array index object associated with a provided identifier.\n*\n* @name free\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {boolean} boolean indicating whether an array index object was successfully freed\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns <ArrayIndex>\n*\n* // ...\n*\n* var out = ArrayIndex.free( idx.id );\n* // returns true\n*/\nsetReadOnly( ArrayIndex, 'free', function free( id ) {\n\tvar node;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn false;\n\t}\n\tv = node.value;\n\n\t// Invalidate the array instance object:\n\tsetReadOnly( v.ref, '_invalidated', true );\n\n\t// Remove the array instance from the cache:\n\tcache.remove( node );\n\n\t// Remove the reference to the original array:\n\tv.data = null;\n\n\treturn true;\n});\n\n/**\n* Returns the array associated with a provided identifier.\n*\n* @name get\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {(Object|null)} object containing array index data\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns <ArrayIndex>\n*\n* // ...\n*\n* var o = ArrayIndex.get( idx.id );\n* // returns {...}\n*\n* var d = o.data;\n* // returns <Uint8Array>[ 1, 0, 1, 0 ]\n*\n* var t = o.type;\n* // returns 'mask'\n*\n* var dt = o.dtype;\n* // returns 'uint8'\n*/\nsetReadOnly( ArrayIndex, 'get', function get( id ) {\n\tvar node;\n\tvar out;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn null;\n\t}\n\tv = node.value;\n\n\t// Assemble the output object:\n\tout = {\n\t\t'data': v.data,\n\t\t'type': v.type,\n\t\t'dtype': v.dtype\n\t};\n\n\t// If the array index object should not be persisted, go ahead and remove the object from the cache...\n\tif ( !v.persist ) {\n\t\tArrayIndex.free( id ); // note: this should come last, after having retrieved all desired array index node data\n\t}\n\treturn out;\n});\n\n/**\n* Returns the underlying array data of array index object.\n*\n* @name data\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {Collection}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var v = idx.data;\n* // returns <Uint8Array>[ 1, 0, 1, 0 ]\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'data', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.data;\n});\n\n/**\n* Returns the underlying array data type of array index object.\n*\n* @name dtype\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var t = idx.dtype;\n* // returns 'uint8'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'dtype', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.dtype;\n});\n\n/**\n* Returns the identifier associated with an array index object.\n*\n* @name id\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var id = idx.id;\n* // returns <string>\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'id', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.id;\n});\n\n/**\n* Returns a boolean indicating if an array index is actively cached.\n*\n* @name isCached\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {boolean}\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var out = idx.isCached;\n* // returns true\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'isCached', function get() {\n\treturn !this._invalidated;\n});\n\n/**\n* Returns the type of array index object.\n*\n* @name type\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var t = idx.type;\n* // returns 'mask'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'type', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.type;\n});\n\n/**\n* Serializes an array index object to a string.\n*\n* @name toString\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {string} serialized array index object\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var str = idx.toString();\n* // e.g., 'ArrayIndex<0>'\n*/\nsetReadOnly( ArrayIndex.prototype, 'toString', function toString() {\n\tvar v;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\treturn 'ArrayIndex<' + v.id + '>';\n});\n\n/**\n* Serializes an array index object as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ArrayIndex` instance.\n*\n* @name toJSON\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {Object} serialized array index object\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var o = idx.toJSON();\n* // returns { 'type': 'ArrayIndex', 'data': { 'type': 'Uint8Array', 'data': [ 1, 0, 1, 0 ] } }\n*/\nsetReadOnly( ArrayIndex.prototype, 'toJSON', function toJSON() {\n\tvar v;\n\tvar o;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\tif ( v.dtype === 'generic' || v.dtype === null ) {\n\t\tif ( isAccessorArray( v.data ) ) {\n\t\t\to = copy( v.data );\n\t\t} else {\n\t\t\to = v.data;\n\t\t}\n\t} else {\n\t\to = array2json( v.data );\n\t}\n\treturn {\n\t\t'type': 'ArrayIndex',\n\t\t'data': o\n\t};\n});\n\n\n// EXPORTS //\n\nmodule.exports = ArrayIndex;\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* Array index constructor.\n*\n* @module @stdlib/array-index\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var ArrayIndex = require( '@stdlib/array-index' );\n*\n* var x = new Uint8Array( [ 1, 0, 1, 0 ] );\n*\n* var idx = new ArrayIndex( x );\n* // returns <ArrayIndex>\n*/\n\n//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,OAAQ,UAAe,CACjE,GAAK,KAAK,aACT,MAAM,IAAI,MAAO,gGAAiG,EAEnH,OAAO,KAAK,MAAM,MAAM,IACzB,CAAC,EAoBDhB,EAAagB,EAAW,UAAW,WAAY,UAAoB,CAClE,IAAIO,EACJ,GAAK,KAAK,aACT,MAAM,IAAI,MAAO,gGAAiG,EAEnH,OAAAA,EAAI,KAAK,MAAM,MACR,cAAgBA,EAAE,GAAK,GAC/B,CAAC,EAwBDvB,EAAagB,EAAW,UAAW,SAAU,UAAkB,CAC9D,IAAIO,EACAI,EACJ,GAAK,KAAK,aACT,MAAM,IAAI,MAAO,gGAAiG,EAEnH,OAAAJ,EAAI,KAAK,MAAM,MACVA,EAAE,QAAU,WAAaA,EAAE,QAAU,KACpClB,EAAiBkB,EAAE,IAAK,EAC5BI,EAAInB,EAAMe,EAAE,IAAK,EAEjBI,EAAIJ,EAAE,KAGPI,EAAIrB,EAAYiB,EAAE,IAAK,EAEjB,CACN,KAAQ,aACR,KAAQI,CACT,CACD,CAAC,EAKD7B,EAAO,QAAUkB,ICzZjB,IAAIY,EAAO,IAKX,OAAO,QAAUA",
4
+ "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// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} defaults\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'persist': 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 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.persist] - boolean indicating whether to continue persisting an index object after first usage\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'persist': 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, 'persist' ) ) {\n\t\topts.persist = options.persist;\n\t\tif ( !isBoolean( opts.persist ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'persist', opts.persist ) );\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 LinkedList = require( '@stdlib/utils-linked-list' );\n\n\n// MAIN //\n\n/**\n* Cache for storing index arrays.\n*\n* @private\n* @name cache\n* @type {LinkedList}\n*/\nvar cache = new LinkedList(); // note: created as a linked list to allow for more efficient removal of expired index arrays\n\n\n// EXPORTS //\n\nmodule.exports = cache;\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 cache = require( './cache.js' );\n\n\n// MAIN //\n\n/**\n* Returns an array index object associated with a specified identifier.\n*\n* @private\n* @param {*} id - identifier\n* @returns {(Node|null)} array index object\n*/\nfunction find( id ) { // eslint-disable-line stdlib/no-redeclare\n\tvar node = cache.first();\n\twhile ( node ) {\n\t\tif ( node.value.id === id ) {\n\t\t\treturn node;\n\t\t}\n\t\tnode = node.next;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = find;\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// VARIABLES //\n\nvar COUNTER = -1; // TODO: consider another approach for unique identifier generation. For most cases, this should suffice; however, it is possible that two different libraries, both relying on separate copies of this package, may trigger id collisions in the event that instantiated instances were to interact (e.g., a consumer attempting to free an instance instantiated by another copy of the package, etc).\n\n\n// MAIN //\n\n/**\n* Generates a new identifier.\n*\n* @private\n* @returns {string} identifier\n*\n* @example\n* var v = id();\n* // returns <string>\n*/\nfunction id() {\n\tCOUNTER += 1;\n\treturn COUNTER.toString();\n}\n\n\n// EXPORTS //\n\nmodule.exports = id;\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/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar array2json = require( '@stdlib/array-to-json' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar copy = require( '@stdlib/array-base-copy' );\nvar resolveGetter = require( '@stdlib/array-base-resolve-getter' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.js' );\nvar validate = require( './validate.js' );\nvar cache = require( './cache.js' );\nvar findArrayIndex = require( './find.js' );\nvar generateId = require( './id.js' );\n\n\n// MAIN //\n\n/**\n* Array index constructor.\n*\n* @param {Collection} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.persist=false] - boolean indicating whether to continue persisting an index object after first usage\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} first argument must be a valid index array\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayIndex} ArrayIndex instance\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var x = new Uint8Array( [ 1, 0, 1, 0 ] );\n*\n* var idx = new ArrayIndex( x );\n* // returns <ArrayIndex>\n*/\nfunction ArrayIndex( x ) {\n\tvar opts;\n\tvar err;\n\tvar get;\n\tvar dt;\n\tvar t;\n\tvar v;\n\tif ( !(this instanceof ArrayIndex) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new ArrayIndex( x, arguments[ 1 ] );\n\t\t}\n\t\treturn new ArrayIndex( x );\n\t}\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tdt = dtype( x );\n\n\t// When provided a \"generic\" array or an array of an unknown data type, attempt to infer the type of index array...\n\tif ( dt === 'generic' || dt === null ) {\n\t\tif ( x.length > 0 ) {\n\t\t\tget = resolveGetter( x );\n\t\t\tv = get( x, 0 );\n\n\t\t\t// Infer the \"type\" of index array from the first element...\n\t\t\tif ( isBoolean( v ) ) {\n\t\t\t\tt = 'bool';\n\t\t\t} else if ( isInteger( v ) ) {\n\t\t\t\tt = 'int';\n\t\t\t} else {\n\t\t\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t\t\t}\n\t\t} else {\n\t\t\tt = 'int';\n\t\t}\n\t} else if ( dt === 'int32' ) {\n\t\tt = 'int';\n\t} else if ( dt === 'uint8' ) {\n\t\tt = 'mask';\n\t} else if ( dt === 'bool' ) {\n\t\tt = 'bool';\n\t} else {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t}\n\t// Resolve index options:\n\topts = defaults();\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, arguments[ 1 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Add the array index to the index cache:\n\tcache.push({\n\t\t'id': generateId(),\n\t\t'ref': this,\n\t\t'data': x,\n\t\t'type': t,\n\t\t'dtype': dt,\n\t\t'persist': opts.persist\n\t});\n\n\t// Store a reference to the cache node:\n\tsetReadOnly( this, '_node', cache.last() );\n\n\t// Initialize a boolean flag indicating whether an array index object has been invalidated (i.e., freed):\n\tsetNonEnumerable( this, '_invalidated', false );\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ArrayIndex\n* @readonly\n* @type {string}\n* @default 'ArrayIndex'\n*\n* @example\n* var str = ArrayIndex.name;\n* // returns 'ArrayIndex'\n*/\nsetReadOnly( ArrayIndex, 'name', 'ArrayIndex' );\n\n/**\n* Frees an array index object associated with a provided identifier.\n*\n* @name free\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {boolean} boolean indicating whether an array index object was successfully freed\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns <ArrayIndex>\n*\n* // ...\n*\n* var out = ArrayIndex.free( idx.id );\n* // returns true\n*/\nsetReadOnly( ArrayIndex, 'free', function free( id ) {\n\tvar node;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn false;\n\t}\n\tv = node.value;\n\n\t// Invalidate the array instance object:\n\tsetReadOnly( v.ref, '_invalidated', true );\n\n\t// Remove the array instance from the cache:\n\tcache.remove( node );\n\n\t// Remove the reference to the original array:\n\tv.data = null;\n\n\treturn true;\n});\n\n/**\n* Returns the array associated with a provided identifier.\n*\n* @name get\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {(Object|null)} object containing array index data\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns <ArrayIndex>\n*\n* // ...\n*\n* var o = ArrayIndex.get( idx.id );\n* // returns {...}\n*\n* var d = o.data;\n* // returns <Uint8Array>[ 1, 0, 1, 0 ]\n*\n* var t = o.type;\n* // returns 'mask'\n*\n* var dt = o.dtype;\n* // returns 'uint8'\n*/\nsetReadOnly( ArrayIndex, 'get', function get( id ) {\n\tvar node;\n\tvar out;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn null;\n\t}\n\tv = node.value;\n\n\t// Assemble the output object:\n\tout = {\n\t\t'data': v.data,\n\t\t'type': v.type,\n\t\t'dtype': v.dtype\n\t};\n\n\t// If the array index object should not be persisted, go ahead and remove the object from the cache...\n\tif ( !v.persist ) {\n\t\tArrayIndex.free( id ); // note: this should come last, after having retrieved all desired array index node data\n\t}\n\treturn out;\n});\n\n/**\n* Returns the underlying array data of array index object.\n*\n* @name data\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {Collection}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var v = idx.data;\n* // returns <Uint8Array>[ 1, 0, 1, 0 ]\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'data', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.data;\n});\n\n/**\n* Returns the underlying array data type of array index object.\n*\n* @name dtype\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var t = idx.dtype;\n* // returns 'uint8'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'dtype', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.dtype;\n});\n\n/**\n* Returns the identifier associated with an array index object.\n*\n* @name id\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var id = idx.id;\n* // returns <string>\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'id', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.id;\n});\n\n/**\n* Returns a boolean indicating if an array index is actively cached.\n*\n* @name isCached\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {boolean}\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var out = idx.isCached;\n* // returns true\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'isCached', function get() {\n\treturn !this._invalidated;\n});\n\n/**\n* Returns the type of array index object.\n*\n* @name type\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var t = idx.type;\n* // returns 'mask'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'type', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.type;\n});\n\n/**\n* Serializes an array index object to a string.\n*\n* @name toString\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {string} serialized array index object\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var str = idx.toString();\n* // e.g., 'ArrayIndex<0>'\n*/\nsetReadOnly( ArrayIndex.prototype, 'toString', function toString() {\n\tvar v;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\treturn 'ArrayIndex<' + v.id + '>';\n});\n\n/**\n* Serializes an array index object as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ArrayIndex` instance.\n*\n* @name toJSON\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {Object} serialized array index object\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns <ArrayIndex>\n*\n* var o = idx.toJSON();\n* // returns { 'type': 'ArrayIndex', 'data': { 'type': 'Uint8Array', 'data': [ 1, 0, 1, 0 ] } }\n*/\nsetReadOnly( ArrayIndex.prototype, 'toJSON', function toJSON() {\n\tvar v;\n\tvar o;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\tif ( v.dtype === 'generic' || v.dtype === null ) {\n\t\tif ( isAccessorArray( v.data ) ) {\n\t\t\to = copy( v.data );\n\t\t} else {\n\t\t\to = v.data;\n\t\t}\n\t} else {\n\t\to = array2json( v.data );\n\t}\n\treturn {\n\t\t'type': 'ArrayIndex',\n\t\t'data': o\n\t};\n});\n\n\n// EXPORTS //\n\nmodule.exports = ArrayIndex;\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* Array index constructor.\n*\n* @module @stdlib/array-index\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var ArrayIndex = require( '@stdlib/array-index' );\n*\n* var x = new Uint8Array( [ 1, 0, 1, 0 ] );\n*\n* var idx = new ArrayIndex( x );\n* // returns <ArrayIndex>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgCA,SAASC,GAAW,CACnB,MAAO,CACN,QAAW,EACZ,CACD,CAKAD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAwB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMN,EAAUM,CAAQ,EAGnBL,EAAYK,EAAS,SAAU,IACnCD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QAAU,WAAaA,EAAE,QAAU,KACpClB,EAAiBkB,EAAE,IAAK,EAC5BI,EAAInB,EAAMe,EAAE,IAAK,EAEjBI,EAAIJ,EAAE,KAGPI,EAAIrB,EAAYiB,EAAE,IAAK,EAEjB,CACN,KAAQ,aACR,KAAQI,CACT,CACD,CAAC,EAKD7B,EAAO,QAAUkB,IC3ZjB,IAAIY,EAAO,IAKX,OAAO,QAAUA",
6
6
  "names": ["require_defaults", "__commonJSMin", "exports", "module", "defaults", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "format", "validate", "opts", "options", "require_cache", "__commonJSMin", "exports", "module", "LinkedList", "cache", "require_find", "__commonJSMin", "exports", "module", "cache", "find", "id", "node", "require_id", "__commonJSMin", "exports", "module", "COUNTER", "id", "require_main", "__commonJSMin", "exports", "module", "setReadOnlyAccessor", "setReadOnly", "setNonEnumerable", "isCollection", "isBoolean", "isInteger", "isAccessorArray", "array2json", "dtype", "copy", "resolveGetter", "format", "defaults", "validate", "cache", "findArrayIndex", "generateId", "ArrayIndex", "x", "opts", "err", "get", "dt", "t", "v", "id", "node", "out", "o", "main"]
7
7
  }
@@ -20,7 +20,7 @@
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { BooleanIndexArray, IntegerIndexArray, IndexArray, MaskArrayIndex, Int32ArrayIndex, BooleanArrayIndex, IntegerArrayIndex, ArrayIndex, BaseIndexArrayObject, IndexArrayObject } from '@stdlib/types/array';
23
+ import { GenericBooleanIndexArray, GenericIntegerIndexArray, IndexArray, MaskArrayIndex, BooleanArrayIndex, Int32ArrayIndex, GenericBooleanArrayIndex, GenericIntegerArrayIndex, ArrayIndex, BaseIndexArrayObject, IndexArrayObject, BooleanArray } from '@stdlib/types/array';
24
24
 
25
25
  /**
26
26
  * Interface describing function options.
@@ -54,6 +54,24 @@ interface Constructor {
54
54
  */
55
55
  new( x: Uint8Array, options?: Options ): MaskArrayIndex;
56
56
 
57
+ /**
58
+ * Array index constructor.
59
+ *
60
+ * @param x - input array
61
+ * @param options - function options
62
+ * @param options.persist - boolean indicating whether to continue persisting an index object after first usage
63
+ * @returns ArrayIndex instance
64
+ *
65
+ * @example
66
+ * var BooleanArray = require( '@stdlib/array-bool' );
67
+ *
68
+ * var x = new BooleanArray( [ true, false, true, false ] );
69
+ *
70
+ * var idx = new ArrayIndex( x );
71
+ * // returns <ArrayIndex>
72
+ */
73
+ new( x: BooleanArray, options?: Options ): BooleanArrayIndex;
74
+
57
75
  /**
58
76
  * Array index constructor.
59
77
  *
@@ -86,7 +104,7 @@ interface Constructor {
86
104
  * var idx = new ArrayIndex( x );
87
105
  * // returns <ArrayIndex>
88
106
  */
89
- new( x: IntegerIndexArray, options?: Options ): IntegerArrayIndex;
107
+ new( x: GenericIntegerIndexArray, options?: Options ): GenericIntegerArrayIndex;
90
108
 
91
109
  /**
92
110
  * Array index constructor.
@@ -102,7 +120,7 @@ interface Constructor {
102
120
  * var idx = new ArrayIndex( x );
103
121
  * // returns <ArrayIndex>
104
122
  */
105
- new( x: BooleanIndexArray, options?: Options ): BooleanArrayIndex;
123
+ new( x: GenericBooleanIndexArray, options?: Options ): GenericBooleanArrayIndex;
106
124
 
107
125
  /**
108
126
  * Array index constructor.
@@ -140,6 +158,24 @@ interface Constructor {
140
158
  */
141
159
  ( x: Uint8Array, options?: Options ): MaskArrayIndex;
142
160
 
161
+ /**
162
+ * Array index constructor.
163
+ *
164
+ * @param x - input array
165
+ * @param options - function options
166
+ * @param options.persist - boolean indicating whether to continue persisting an index object after first usage
167
+ * @returns ArrayIndex instance
168
+ *
169
+ * @example
170
+ * var BooleanArray = require( '@stdlib/array-bool' );
171
+ *
172
+ * var x = new BooleanArray( [ true, false, true, false ] );
173
+ *
174
+ * var idx = ArrayIndex( x );
175
+ * // returns <ArrayIndex>
176
+ */
177
+ ( x: BooleanArray, options?: Options ): BooleanArrayIndex;
178
+
143
179
  /**
144
180
  * Array index constructor.
145
181
  *
@@ -172,7 +208,7 @@ interface Constructor {
172
208
  * var idx = ArrayIndex( x );
173
209
  * // returns <ArrayIndex>
174
210
  */
175
- ( x: IntegerIndexArray, options?: Options ): IntegerArrayIndex;
211
+ ( x: GenericIntegerIndexArray, options?: Options ): GenericIntegerArrayIndex;
176
212
 
177
213
  /**
178
214
  * Array index constructor.
@@ -188,7 +224,7 @@ interface Constructor {
188
224
  * var idx = ArrayIndex( x );
189
225
  * // returns <ArrayIndex>
190
226
  */
191
- ( x: BooleanIndexArray, options?: Options ): BooleanArrayIndex;
227
+ ( x: GenericBooleanIndexArray, options?: Options ): GenericBooleanArrayIndex;
192
228
 
193
229
  /**
194
230
  * Array index constructor.
package/lib/main.js CHANGED
@@ -102,6 +102,8 @@ function ArrayIndex( x ) {
102
102
  t = 'int';
103
103
  } else if ( dt === 'uint8' ) {
104
104
  t = 'mask';
105
+ } else if ( dt === 'bool' ) {
106
+ t = 'bool';
105
107
  } else {
106
108
  throw new TypeError( 'invalid argument. First argument must be a valid index array.' );
107
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-index",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Array index constructor.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,22 +30,22 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/array-base-assert-is-accessor-array": "^0.2.1",
33
+ "@stdlib/array-base-assert-is-accessor-array": "^0.2.2",
34
34
  "@stdlib/array-base-copy": "^0.2.1",
35
- "@stdlib/array-base-resolve-getter": "^0.2.0",
35
+ "@stdlib/array-base-resolve-getter": "^0.2.1",
36
36
  "@stdlib/array-dtype": "^0.2.1",
37
- "@stdlib/array-to-json": "^0.2.1",
38
- "@stdlib/assert-has-own-property": "^0.2.1",
39
- "@stdlib/assert-is-boolean": "^0.2.1",
40
- "@stdlib/assert-is-collection": "^0.2.1",
41
- "@stdlib/assert-is-integer": "^0.2.1",
42
- "@stdlib/assert-is-plain-object": "^0.2.1",
43
- "@stdlib/string-format": "^0.2.1",
44
- "@stdlib/utils-define-nonenumerable-property": "^0.2.1",
45
- "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2",
46
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1",
47
- "@stdlib/utils-linked-list": "^0.2.1",
48
- "@stdlib/error-tools-fmtprodmsg": "^0.2.1"
37
+ "@stdlib/array-to-json": "^0.3.0",
38
+ "@stdlib/assert-has-own-property": "^0.2.2",
39
+ "@stdlib/assert-is-boolean": "^0.2.2",
40
+ "@stdlib/assert-is-collection": "^0.2.2",
41
+ "@stdlib/assert-is-integer": "^0.2.2",
42
+ "@stdlib/assert-is-plain-object": "^0.2.2",
43
+ "@stdlib/string-format": "^0.2.2",
44
+ "@stdlib/utils-define-nonenumerable-property": "^0.2.2",
45
+ "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3",
46
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
47
+ "@stdlib/utils-linked-list": "^0.2.2",
48
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
49
49
  },
50
50
  "devDependencies": {},
51
51
  "engines": {