From af9eb61c99561ed13e82da0735d98c33fe671304 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 24 Apr 2025 18:31:01 +0530 Subject: [PATCH 01/18] feat: add array/base/to-inserted-at --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/lib/assign.js | 234 ++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js new file mode 100644 index 000000000000..c21a2ea64ca7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -0,0 +1,234 @@ +/** +* @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 isComplexDataType = require( '@stdlib/array/base/assert/is-complex-floating-point-data-type' ); +var isBooleanDataType = require( '@stdlib/array/base/assert/is-boolean-data-type' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var Boolean = require( '@stdlib/boolean/ctor' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); +var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var format = require( '@stdlib/string/format' ); + + +// FUNCTIONS // + +/** +* Copies elements from one array to another array and inserts the element at the specified index to a provided value. +* +* @private +* @param {Collection} x - input array +* @param {integer} index - element index +* @param {*} value - inserting value +* @param {Collection} out - output array +* @param {integer} stride - output array stride +* @param {NonNegativeInteger} offset - output array offset +* @returns {Collection} output array +* +* @example +* var x = [ 1, 2, 3, 4 ]; +* +* var out = [ 0, 0, 0, 0, 0 ]; +* var arr = indexed( x, 0, 5, out, 1, 0 ); +* // returns [ 5, 1, 2, 3, 4 ] +* +* var bool = ( arr === out ); +* // returns true +*/ +function indexed( x, index, value, out, stride, offset ) { + var io; + var i; + + io = offset; + for ( i = 0; i < x.length; i++ ) { + out[ io ] = x[ i ]; + io += stride; + } + for ( i = x.length - 1; i >= index; i-- ) { + out[ offset + ((i + 1) * stride) ] = out[ offset + (i * stride) ]; + } + out[ offset + (index * stride) ] = value; + + return out; +} + +/** +* Copies elements from one accessor array to another accessor array and inserts the element at the specified index to a provided value. +* +* @private +* @param {Object} x - input array object +* @param {integer} index - element index +* @param {*} value - inserting value +* @param {Object} out - output array object +* @param {integer} stride - output array stride +* @param {NonNegativeInteger} offset - output array offset +* @returns {Collection} output array +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); +* +* var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); +* var arr = accessors( arraylike2object( x ), 0, 5, arraylike2object( out ), 1, 0 ); +* +* var v = arr.get( 0 ); +* // returns 5 +*/ +function accessors( x, index, value, out, stride, offset ) { + var xdata; + var odata; + var xget; + var oset; + var io; + var i; + + xdata = x.data; + odata = out.data; + + xget = x.accessors[ 0 ]; + oset = out.accessors[ 1 ]; + + io = offset; + for ( i = 0; i < xdata.length; i++ ) { + oset( odata, io, xget( xdata, i ) ); + io += stride; + } + for ( i = xdata.length - 1; i >= index; i-- ) { + oset( odata, offset + ((i + 1) * stride), xget( odata, offset + (i * stride) ) ); + } + + oset( odata, offset + (index * stride), value ); + return odata; +} + +/** +* Copies elements from one complex array to another complex array and inserts the element at the specified index to a provided value. +* +* @private +* @param {Collection} x - real-valued floating-point input array view +* @param {integer} index - element index +* @param {ComplexLike} value - inserting value +* @param {Collection} out - real-valued floating-point output array view +* @param {integer} stride - output array stride +* @param {NonNegativeInteger} offset - output array offset +* @returns {Collection} output array view +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* +* var out = new Float64Array( 6 ); +* var arr = complex( x, 0, new Complex128( 5.0, 6.0 ), out, 1, 0 ); +* // returns [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +*/ +function complex( x, index, value, out, stride, offset ) { + var so; + var io; + var i; + + so = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components + io = offset * 2; + for ( i = 0; i < x.length/2; i++ ) { + out[ io + ( i * so ) ] = x[ 2 * i ]; + out[ io + ( i * so ) + 1 ] = x[ ( 2 * i ) + 1 ]; + } + for ( i = ( x.length/2 ) - 1; i >= index; i-- ) { + out[ io + ( ( i + 1 ) * so ) ] = out[ io + ( i * so ) ]; + out[ ( io + ( ( i + 1 ) * so ) ) + 1] = out[ io + ( i * so ) + 1]; + } + out[ io + ( index * so ) ] = real( value ); + out[ io + ( index * so ) + 1] = imag( value ); + + return out; +} + + +// MAIN // + +/** +* Copies elements from one array to another array and inserts the element at the specified index to a provided value. +* +* @param {Collection} x - input array +* @param {integer} index - element index +* @param {*} value - inserting value +* @param {Collection} out - output array +* @param {integer} stride - output array stride +* @param {NonNegativeInteger} offset - output array offset +* @throws {RangeError} second argument must not exceed array bounds +* @returns {Collection} output array +* +* @example +* var x = [ 1, 2, 3, 4 ]; +* +* var out = [ 0, 0, 0, 0, 0 ]; +* var arr = assign( x, 0, 5, out, 1, 0 ); +* // returns [ 5, 1, 2, 3, 4 ] +* +* var bool = ( arr === out ); +* // returns true +*/ +function assign( x, index, value, out, stride, offset ) { + var xo; + var oo; + + index = normalizeIndex( index, x.length-1 ); + if ( index < 0 ) { + throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); + } + xo = arraylike2object( x ); + oo = arraylike2object( out ); + if ( xo.accessorProtocol || oo.accessorProtocol ) { + // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... + if ( + isComplexDataType( xo.dtype ) && + isComplexDataType( oo.dtype ) && + isComplexLike( value ) + ) { + complex( reinterpret( x, 0 ), index, value, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len + return out; + } + if ( + isBooleanDataType( xo.dtype ) && + isBooleanDataType( oo.dtype ) + ) { + indexed( reinterpretBoolean( x, 0 ), index, Boolean( value ), reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len + return out; + } + accessors( xo, index, value, oo, stride, offset ); + return out; + } + indexed( x, index, value, out, stride, offset ); + return out; +} + + +// EXPORTS // + +module.exports = assign; From 5775b3b81d644bf7478823efd63ad55005b1ccc3 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 24 Apr 2025 19:20:02 +0530 Subject: [PATCH 02/18] docs: add implementations --- .../benchmark/benchmark.assign.length.js | 98 +++++++ .../benchmark/benchmark.length.js | 96 +++++++ .../array/base/to-inserted-at/docs/repl.txt | 79 ++++++ .../base/to-inserted-at/docs/types/index.d.ts | 251 ++++++++++++++++++ .../base/to-inserted-at/docs/types/test.ts | 170 ++++++++++++ .../array/base/to-inserted-at/lib/index.js | 64 +++++ .../array/base/to-inserted-at/lib/main.js | 91 +++++++ 7 files changed, 849 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js new file mode 100644 index 000000000000..ef056bd4cd1d --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js @@ -0,0 +1,98 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isArray = require( '@stdlib/assert/is-array' ); +var ones = require( '@stdlib/array/base/ones' ); +var zeros = require( '@stdlib/array/base/zeros' ); +var pkg = require( './../package.json' ).name; +var array2insertedAt = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var out = zeros( len ); + var x = ones( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = array2insertedAt.assign( x, i%len, i, out, 1, 0 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + f = createBenchmark( len ); + bench( pkg+':assign:dtype=generic,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js new file mode 100644 index 000000000000..76711eef7047 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isArray = require( '@stdlib/assert/is-array' ); +var ones = require( '@stdlib/array/base/ones' ); +var pkg = require( './../package.json' ).name; +var array2insertedAt = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = array2insertedAt( x, i%len, i ); + if ( out.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isArray( out ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + f = createBenchmark( len ); + bench( pkg+':dtype=generic,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt new file mode 100644 index 000000000000..8fb21d98a976 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt @@ -0,0 +1,79 @@ + +{{alias}}( x, index, value ) + Returns a new array with the element at the specified index inserted with a + provided value. + + Negative indices are resolved relative to the last array element, with the + last element corresponding to `-1`. + + Parameters + ---------- + x: ArrayLikeObject + Input array. + + index: integer + Index of the element to be inserted. + + value: any + Inserting value. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var x = [ 1, 2, 3, 4 ]; + > {{alias}}( x, 0, 5 ) + [ 5, 1, 2, 3, 4 ] + > {{alias}}( x, -1, 6 ) + [ 1, 2, 3, 4, 6 ] + > x + [ 1, 2, 3, 4 ] + + +{{alias}}.assign( x, index, value, out, stride, offset ) + Copies elements from one array to another array and inserts the element at the + specified index to a provided value. + + Negative indices are resolved relative to the last array element, with the + last element corresponding to `-1`. + + Parameters + ---------- + x: ArrayLikeObject + Input array. + + index: integer + Index of the element to be inserted. + + value: any + Inserting value. + + out: ArrayLikeObject + Output array. + + stride: integer + Output array stride. + + offset: integer + Output array offset. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var x = [ 1, 2, 3, 4 ]; + > var out = [ 0, 0, 0, 0, 0 ]; + > var arr = {{alias}}.assign( x, 0, 5, out, 1, 0 ) + [ 5, 1, 2, 3, 4 ] + > var bool = ( arr === out ) + true + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts new file mode 100644 index 000000000000..8a678213ffbc --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts @@ -0,0 +1,251 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, RealTypedArray, ComplexTypedArray, AccessorArrayLike } from '@stdlib/types/array'; +import { ComplexLike } from '@stdlib/types/complex'; + +/** +* Interface describing `array2InsertedAt`. +*/ +interface Array2InsertedAt { + /** + * Returns a new array with the element at the specified index inserted with a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @returns output array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * + * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * var out = array2InsertedAt( x, 0, new Complex128( 7.0, 8.0 ) ); + * // returns [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] + */ + ( x: T, index: number, value: ComplexLike ): T; + + /** + * Returns a new array with the element at the specified index inserted with a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + * + * var out = array2InsertedAt( x, 0, 5.0 ); + * // returns [ 5.0, 1.0, 2.0, 3.0 ] + */ + ( x: T, index: number, value: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures + + /** + * Returns a new array with the element at the specified index inserted with a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @returns output array + * + * @example + * var x = [ 1, 2, 3 ]; + * + * var out = array2InsertedAt( x, 0, 7 ); + * // returns [ 7, 1, 2, 3 ] + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var out = array2InsertedAt( x, 1, 8 ); + * // returns [ 1, 8, 2, 3, 4, 5, 6 ] + */ + ( x: Collection, index: number, value: T ): Array; + + /** + * Copies elements from one array to another array and inserts the element at the specified index to a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @param out - output array + * @param stride - output array stride + * @param offset - output array offset + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = [ 1, 2, 3, 4 ]; + * + * var out = new Float64Array( [ 0, 0, 0, 0, 0 ] ); + * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * // returns [ 5, 1, 2, 3, 4 ] + * + * var bool = ( arr === out ); + * // returns true + */ + assign( x: Collection | AccessorArrayLike, index: number, value: number, out: T, stride: number, offset: number ): T; + + /** + * Copies elements from one array to another array and inserts the element at the specified index to a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @param out - output array + * @param stride - output array stride + * @param offset - output array offset + * @returns output array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * + * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * var out = new Complex128Array( 4 ); + * var arr = array2InsertedAt.assign( x, 0, new Complex128( 7.0, 8.0 ), out, 1, 0 ); + * // returns [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] + * + * var bool = ( arr === out ); + * // returns true + */ + assign( x: Collection | AccessorArrayLike, index: number, value: ComplexLike, out: T, stride: number, offset: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures + + /** + * Copies elements from one array to another array and inserts the element at the specified index to a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @param out - output array + * @param stride - output array stride + * @param offset - output array offset + * @returns output array + * + * @example + * var x = [ 1, 2, 3, 4 ]; + * + * var out = [ 0, 0, 0, 0, 0 ]; + * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * // returns [ 5, 1, 2, 3, 4 ] + * + * var bool = ( arr === out ); + * // returns true + */ + assign( x: Collection | AccessorArrayLike, index: number, value: U, out: Array, stride: number, offset: number ): Array; + + /** + * Copies elements from one array to another array and inserts the element at the specified index to a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @param out - output array + * @param stride - output array stride + * @param offset - output array offset + * @returns output array + * + * @example + * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); + * + * var x = toAccessorArray( [ 1, 2, 3, 4 ] ); + * + * var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); + * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * + * var v = out[ 0 ]; + * // returns 5 + * + * var bool = ( arr === out ); + * // returns true + */ + assign( x: Collection | AccessorArrayLike, index: number, value: U, out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; + + /** + * Copies elements from one array to another array and inserts the element at the specified index to a provided value. + * + * @param x - input array + * @param index - index at which to set a provided value + * @param value - inserting value + * @param out - output array + * @param stride - output array stride + * @param offset - output array offset + * @returns output array + * + * @example + * var x = [ 1, 2, 3, 4 ]; + * + * var out = [ 0, 0, 0, 0, 0 ]; + * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * // returns [ 5, 1, 2, 3, 4 ] + * + * var bool = ( arr === out ); + * // returns true + */ + assign( x: Collection | AccessorArrayLike, index: number, value: U, out: Collection, stride: number, offset: number ): Collection; +} + +/** +* Returns a new array with the element at the specified index inserted with a provided value. +* +* @param x - input array +* @param index - index at which to set a provided value +* @param value - inserting value +* @returns output array +* +* @example +* var x = [ 1, 2, 3 ]; +* +* var out = array2InsertedAt( x, 0, 7 ); +* // returns [ 7, 1, 2, 3 ] +* +* @example +* var x = [ 1, 2, 3, 4, 5, 6 ]; +* +* var out = array2InsertedAt( x, 1, 8 ); +* // returns [ 1, 8, 2, 3, 4, 5, 6 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = [ 1, 2, 3, 4 ]; +* +* var out = new Float64Array( [ 0, 0, 0, 0, 0 ] ); +* var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); +* // returns [ 5, 1, 2, 3, 4 ] +* +* var bool = ( arr === out ); +* // returns true +*/ +declare var array2InsertedAt: Array2InsertedAt; + + +// EXPORTS // + +export = array2InsertedAt; diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts new file mode 100644 index 000000000000..1a4f9a8bf151 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts @@ -0,0 +1,170 @@ +/* +* @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. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import Complex64Array = require( '@stdlib/array/complex64' ); +import toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +import array2InsertedAt = require( './index' ); + + +// TESTS // + +// The function returns an updated array... +{ + array2InsertedAt( [ 1, 2, 3, 4 ], 0, 5 ); // $ExpectType number[] + array2InsertedAt( new Complex128Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex128Array + array2InsertedAt( new Complex64Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex64Array + array2InsertedAt( toAccessorArray( [ 1, 2, 3, 4 ] ), 0, 5 ); // $ExpectType number[] +} + +// The compiler throws an error if the function is provided a first argument which is not a collection... +{ + array2InsertedAt( 5, 0, 5 ); // $ExpectError + array2InsertedAt( true, 0, 5 ); // $ExpectError + array2InsertedAt( false, 0, 5 ); // $ExpectError + array2InsertedAt( null, 0, 5 ); // $ExpectError + array2InsertedAt( void 0, 0, 5 ); // $ExpectError + array2InsertedAt( {}, 0, 5 ); // $ExpectError + array2InsertedAt( ( x: number ): number => x, 0, 5 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = [ 1, 2, 3, 4 ]; + + array2InsertedAt( x, 'abc', 5 ); // $ExpectError + array2InsertedAt( x, true, 5 ); // $ExpectError + array2InsertedAt( x, false, 5 ); // $ExpectError + array2InsertedAt( x, null, 5 ); // $ExpectError + array2InsertedAt( x, void 0, 5 ); // $ExpectError + array2InsertedAt( x, [ '1' ], 5 ); // $ExpectError + array2InsertedAt( x, {}, 5 ); // $ExpectError + array2InsertedAt( x, ( x: number ): number => x, 5 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = [ 1, 2, 3, 4 ]; + + array2InsertedAt(); // $ExpectError + array2InsertedAt( x ); // $ExpectError + array2InsertedAt( x, 0 ); // $ExpectError + array2InsertedAt( x, 0, 0, 5 ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a collection... +{ + const x = [ 1, 2, 3, 4 ]; + const y = new Complex128Array( 4 ); + + array2InsertedAt.assign( x, 0, 5, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] + array2InsertedAt.assign( x, 0, 5, new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array + array2InsertedAt.assign( x, 0, 5, new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array + array2InsertedAt.assign( x, 0, 5, new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array + array2InsertedAt.assign( x, 0, 5, new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array + array2InsertedAt.assign( x, 0, 5, new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array + array2InsertedAt.assign( x, 0, 5, new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array + array2InsertedAt.assign( x, 0, 5, new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array + array2InsertedAt.assign( x, 0, 5, new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array + array2InsertedAt.assign( x, 0, 5, new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray + array2InsertedAt.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array + array2InsertedAt.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... +{ + const out = [ 0, 0, 0, 0 ]; + + array2InsertedAt.assign( 1, 0, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( true, 0, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( false, 0, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( null, 0, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( void 0, 0, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( {}, 0, 5, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not a number... +{ + const x = [ 1, 2, 3, 4 ]; + const out = [ 0, 0, 0, 0 ]; + + array2InsertedAt.assign( x, '1', 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, true, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, false, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, null, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, void 0, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, [], 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, {}, 5, out, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, ( x: number ): number => x, 5, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... +{ + const x = [ 1, 2, 3, 4 ]; + + array2InsertedAt.assign( x, 0, 5, 1, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 5, true, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 5, false, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 5, null, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 5, void 0, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 5, {}, 1, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 5, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... +{ + const x = [ 1, 2, 3, 4 ]; + const out = [ 0, 0, 0, 0 ]; + + array2InsertedAt.assign( x, 0, 1, out, '1', 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, true, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, false, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, null, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, void 0, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, [], 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, {}, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... +{ + const x = [ 1, 2, 3, 4 ]; + const out = [ 0, 0, 0, 0 ]; + + array2InsertedAt.assign( x, 0, 1, out, 1, '1' ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, true ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, false ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, null ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, void 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, [] ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, {} ); // $ExpectError + array2InsertedAt.assign( x, 0, 1, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const x = [ 1, 2, 3, 4 ]; + const out = [ 0, 0, 0, 0 ]; + + array2InsertedAt.assign(); // $ExpectError + array2InsertedAt.assign( x ); // $ExpectError + array2InsertedAt.assign( x, 0 ); // $ExpectError + array2InsertedAt.assign( x, 0, 0, out ); // $ExpectError + array2InsertedAt.assign( x, 0, 0, out, 1 ); // $ExpectError + array2InsertedAt.assign( x, 0, 0, out, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js new file mode 100644 index 000000000000..f696e150756d --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js @@ -0,0 +1,64 @@ +/** +* @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'; + +/** +* Return a new array with the element at the specified index inserted with a provided value. +* +* @module @stdlib/array/base/to-inserted-at +* +* @example +* var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +* +* var x = [ 1, 2, 3, 4 ]; +* +* var v = array2InsertedAt( x, 0, 5 ); +* // returns [ 5, 1, 2, 3, 4 ] +* +* v = array2InsertedAt( x, -2, -1 ); +* // returns [ 1, 2, 3, -1, 4 ] +* +* @example +* var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +* +* var x = [ 1, 2, 3, 4 ]; +* +* var out = [ 0, 0, 0, 0 ]; +* var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); +* // returns [ 5, 1, 2, 3, 4 ] +* +* var bool = ( arr === out ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js new file mode 100644 index 000000000000..3da337d5feed --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -0,0 +1,91 @@ +/** +* @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 normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var zeros = require( '@stdlib/array/zeros' ); +var dtype = require( '@stdlib/array/dtype' ); +var format = require( '@stdlib/string/format' ); +var assign = require( './assign.js' ); + + +// FUNCTIONS // + +/** +* Tests whether an object has a specified method. +* +* @private +* @param {Object} obj - input object +* @param {string} method - method name +* @returns {boolean} boolean indicating whether an object has a specified method +* +* @example +* var bool = hasMethod( [], 'map' ); +* // returns true +* +* @example +* var bool = hasMethod( [], 'beep' ); +* // returns false +*/ +function hasMethod( obj, method ) { + return ( typeof obj[ method ] === 'function' ); +} + + +// MAIN // + +/** +* Returns a new array with the element at the specified index inserted with a provided value. +* +* @param {Collection} x - input array +* @param {integer} index - element index +* @param {*} value - inserting value +* @throws {RangeError} second argument must not exceed array bounds +* @returns {Collection} output array +* +* @example +* var x = [ 1, 2, 3, 4 ]; +* +* var v = array2InsertedAt( x, 0, 5 ); +* // returns [ 5, 1, 2, 3, 4 ] +* +* v = array2InsertedAt( x, 1, 6 ); +* // returns [ 1, 6, 2, 3, 4 ] +* +* v = array2InsertedAt( x, -2, 7 ); +* // returns [ 1, 2, 3, 7, 4 ] +*/ +function array2InsertedAt( x, index, value ) { + var out; + + index = normalizeIndex( index, x.length-1 ); + if ( index < 0 ) { + throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); + } + out = zeros( x.length-1, dtype( x ) || 'generic' ); + assign( x, index, value, out, 1, 0 ); + return out; +} + + +// EXPORTS // + +module.exports = array2InsertedAt; From 7a03202ad6ea375706ef1db3643d16584eed2cae Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 00:08:01 +0530 Subject: [PATCH 03/18] docs: complete implementations --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/README.md | 161 ++++++ .../benchmark/benchmark.assign.length.js | 4 +- .../benchmark/benchmark.length.js | 4 +- .../base/to-inserted-at/examples/index.js | 40 ++ .../array/base/to-inserted-at/lib/assign.js | 4 +- .../array/base/to-inserted-at/lib/main.js | 27 +- .../array/base/to-inserted-at/package.json | 64 +++ .../base/to-inserted-at/test/test.assign.js | 497 ++++++++++++++++++ .../array/base/to-inserted-at/test/test.js | 41 ++ .../base/to-inserted-at/test/test.main.js | 401 ++++++++++++++ 10 files changed, 1213 insertions(+), 30 deletions(-) create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/README.md create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/package.json create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js create mode 100644 lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md new file mode 100644 index 000000000000..0281caf928ae --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md @@ -0,0 +1,161 @@ + + +# array2InsertedAt + +> Return a new array with the element at the specified index inserted with a provided value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +``` + +#### array2InsertedAt( x, index, value ) + +Returns a new array with the element at the specified index inserted with a provided value. + +```javascript +var x = [ 1, 2, 3, 4 ]; + +var out = array2InsertedAt( x, 0, 5 ); +// returns [ 5, 1, 2, 3, 4 ] + +out = array2InsertedAt( x, -1, 6 ); +// returns [ 1, 2, 3, 6, 4 ] +``` + +The function accepts the following arguments: + +- **x**: an input array. +- **index**: element index. +- **value**: inserting value. + +### array2InsertedAt.assign( x, index, value, out, stride, offset ) + +Copies elements from one array to another array and sets the element at the specified index to a provided value. + +```javascript +var x = [ 1, 2, 3, 4 ]; + +var out = [ 0, 0, 0, 0 ]; +var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); +// returns [ 5, 1, 2, 3, 4 ] + +var bool = ( arr === out ); +// returns true +``` + +The function accepts the following arguments: + +- **x**: an input array. +- **index**: element index. +- **value**: inserting value. +- **out**: output array. +- **stride**: output array stride. +- **offset**: output array offset. + +
+ + + + + +
+ +## Notes + +- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. + + +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); + +// Define an array: +var opts = { + 'dtype': 'generic' +}; +var x = discreteUniform( 5, -100, 100, opts ); + +// Define an array containing random index values: +var indices = discreteUniform( 100, -x.length, x.length-1, opts ); + +// Define an array with random values to set: +var values = discreteUniform( indices.length, -10000, 10000, opts ); + +// Randomly set elements in the input array: +var i; +for ( i = 0; i < indices.length; i++ ) { + console.log( 'x = [%s]', array2InsertedAt( x, indices[ i ], values[ i ] ).join( ',' ) ); +} +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js index ef056bd4cd1d..5fa034a0d0ef 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js @@ -26,7 +26,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var ones = require( '@stdlib/array/base/ones' ); var zeros = require( '@stdlib/array/base/zeros' ); var pkg = require( './../package.json' ).name; -var array2insertedAt = require( './../lib' ); +var array2InsertedAt = require( './../lib' ); // FUNCTIONS // @@ -55,7 +55,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = array2insertedAt.assign( x, i%len, i, out, 1, 0 ); + v = array2InsertedAt.assign( x, i%len, i, out, 1, 0 ); if ( typeof v !== 'object' ) { b.fail( 'should return an array' ); } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js index 76711eef7047..d68e98ddca8d 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js @@ -25,7 +25,7 @@ var pow = require( '@stdlib/math/base/special/pow' ); var isArray = require( '@stdlib/assert/is-array' ); var ones = require( '@stdlib/array/base/ones' ); var pkg = require( './../package.json' ).name; -var array2insertedAt = require( './../lib' ); +var array2InsertedAt = require( './../lib' ); // FUNCTIONS // @@ -53,7 +53,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = array2insertedAt( x, i%len, i ); + out = array2InsertedAt( x, i%len, i ); if ( out.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js new file mode 100644 index 000000000000..5e51cf5c600c --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js @@ -0,0 +1,40 @@ +/** +* @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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var array2InsertedAt = require( './../lib' ); + +// Define an array: +var opts = { + 'dtype': 'generic' +}; +var x = discreteUniform( 5, -100, 100, opts ); + +// Define an array containing random index values: +var indices = discreteUniform( 100, -x.length, x.length-1, opts ); + +// Define an array with random values to set: +var values = discreteUniform( indices.length, -10000, 10000, opts ); + +// Randomly set elements in the input array: +var i; +for ( i = 0; i < indices.length; i++ ) { + console.log( 'x = [%s]', array2InsertedAt( x, indices[ i ], values[ i ] ).join( ',' ) ); +} diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index c21a2ea64ca7..945f3b3ea25e 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -102,6 +102,7 @@ function accessors( x, index, value, out, stride, offset ) { var xdata; var odata; var xget; + var oget; var oset; var io; var i; @@ -110,6 +111,7 @@ function accessors( x, index, value, out, stride, offset ) { odata = out.data; xget = x.accessors[ 0 ]; + oget = out.accessors[ 0 ]; oset = out.accessors[ 1 ]; io = offset; @@ -118,7 +120,7 @@ function accessors( x, index, value, out, stride, offset ) { io += stride; } for ( i = xdata.length - 1; i >= index; i-- ) { - oset( odata, offset + ((i + 1) * stride), xget( odata, offset + (i * stride) ) ); + oset( odata, offset + ((i + 1) * stride), oget( odata, offset + (i * stride) ) ); } oset( odata, offset + (index * stride), value ); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 3da337d5feed..9820736ead8a 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -27,29 +27,6 @@ var format = require( '@stdlib/string/format' ); var assign = require( './assign.js' ); -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'map' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - - // MAIN // /** @@ -71,7 +48,7 @@ function hasMethod( obj, method ) { * // returns [ 1, 6, 2, 3, 4 ] * * v = array2InsertedAt( x, -2, 7 ); -* // returns [ 1, 2, 3, 7, 4 ] +* // returns [ 1, 2, 7, 3, 4 ] */ function array2InsertedAt( x, index, value ) { var out; @@ -80,7 +57,7 @@ function array2InsertedAt( x, index, value ) { if ( index < 0 ) { throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); } - out = zeros( x.length-1, dtype( x ) || 'generic' ); + out = zeros( x.length+1, dtype( x ) || 'generic' ); assign( x, index, value, out, 1, 0 ); return out; } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json b/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json new file mode 100644 index 000000000000..5af160be3793 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/array/base/to-inserted-at", + "version": "0.0.0", + "description": "Return a new array with the element at the specified index inserted with a provided value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "base", + "array", + "typed", + "collection", + "vector", + "inserted", + "insert", + "inserter", + "copy" + ], + "__stdlib__": {} + } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js new file mode 100644 index 000000000000..b64f175909ce --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js @@ -0,0 +1,497 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var AccessorArray = require( '@stdlib/array/base/accessor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var zeros = require( '@stdlib/array/zeros' ); +var array2InsertedAt = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof array2InsertedAt, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (generic)', function test( t ) { + var values; + var out; + var x; + var i; + + x = [ 1, 2, 3 ]; + out = zeros( x.length + 1, 'generic' ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (float64)', function test( t ) { + var values; + var out; + var x; + var i; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = zeros( x.length + 1, 'float64' ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0.0, out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (int32)', function test( t ) { + var values; + var out; + var x; + var i; + + x = new Int32Array( [ 1, 2, 3 ] ); + out = zeros( x.length + 1, 'int32' ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (complex128)', function test( t ) { + var values; + var out; + var x; + var i; + + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + out = zeros( x.length + 1, 'complex128' ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, new Complex128( 0.0, 0.0 ), out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (accessors)', function test( t ) { + var values; + var out; + var x; + var i; + + x = new AccessorArray( [ 1, 2, 3 ] ); + out = new AccessorArray( zeros( x.length + 1, 'generic' ) ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (array-like)', function test( t ) { + var values; + var out; + var x; + var i; + + x = { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + }; + + out = { + 'length': 4, + '0': 0, + '1': 0, + '2': 0, + '3': 0 + }; + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (generic)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = [ 1, 2, 3 ]; + + out = zeros( x.length + 1, 'generic' ); + expected = [ 5, 1, 2, 3 ]; + actual = array2InsertedAt( x, 0, 5, out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'generic' ); + expected = [ 1, 0, 5, 0, 2, 0, 3, 0 ]; + actual = array2InsertedAt( x, 1, 5, out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'generic' ); + expected = [ 0, 3, 0, 5, 0, 2, 0, 1 ]; + actual = array2InsertedAt( x, 2, 5, out, -2, out.length-1 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (float64)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + out = zeros( x.length + 1, 'float64' ); + expected = new Float64Array( [ 5.0, 1.0, 2.0, 3.0 ] ); + actual = array2InsertedAt( x, 0, 5.0, out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'float64' ); + expected = new Float64Array( [ 1.0, 0.0, 5.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + actual = array2InsertedAt( x, 1, 5.0, out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'float64' ); + expected = new Float64Array( [ 0.0, 3.0, 0.0, 5.0, 0.0, 2.0, 0.0, 1.0 ] ); + actual = array2InsertedAt( x, 2, 5.0, out, -2, out.length-1 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (int32)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = new Int32Array( [ 1, 2, 3 ] ); + + out = zeros( x.length + 1, 'int32' ); + expected = new Int32Array( [ 5, 1, 2, 3 ] ); + actual = array2InsertedAt( x, 0, 5, out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'int32' ); + expected = new Int32Array( [ 1, 0, 5, 0, 2, 0, 3, 0 ] ); + actual = array2InsertedAt( x, 1, 5, out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'int32' ); + expected = new Int32Array( [ 0, 3, 0, 5, 0, 2, 0, 1 ] ); + actual = array2InsertedAt( x, 2, 5, out, -2, out.length-1 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (complex128)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = zeros( x.length + 1, 'complex128' ); + expected = new Complex128Array( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + actual = array2InsertedAt( x, 0, new Complex128( 7.0, 8.0 ), out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'complex128' ); + expected = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ] ); // eslint-disable-line max-len + actual = array2InsertedAt( x, 1, new Complex128( 7.0, 8.0 ), out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); + + out = zeros( ( x.length + 1 )*2, 'complex128' ); + expected = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0 ] ); // eslint-disable-line max-len + actual = array2InsertedAt( x, 2, new Complex128( 7.0, 8.0 ), out, -2, out.length-1 ); // eslint-disable-line max-len + + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (bool)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = new BooleanArray( [ 0, 0, 1, 1 ] ); + + out = new BooleanArray( x.length + 1 ); + expected = new BooleanArray( [ 1, 0, 0, 1, 1 ] ); + actual = array2InsertedAt( x, 0, true, out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + + out = new BooleanArray( ( x.length + 1 )*2 ); + expected = new BooleanArray( [ 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 ] ); + actual = array2InsertedAt( x, 1, true, out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + + out = new BooleanArray( ( x.length + 1 )*2 ); + expected = new BooleanArray( [ 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 ] ); + actual = array2InsertedAt( x, 2, false, out, -2, out.length-1 ); + + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (accessors)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = new AccessorArray( [ 1, 2, 3 ] ); + + out = new AccessorArray( zeros( x.length + 1, 'generic' ) ); + expected = [ 5, 1, 2, 3 ]; + actual = array2InsertedAt( x, 0, 5, out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + isEqual( actual, expected ); + + out = new AccessorArray( zeros( ( x.length + 1 )*2, 'generic' ) ); + expected = [ 1, 0, 5, 0, 2, 0, 3, 0 ]; + actual = array2InsertedAt( x, 1, 5, out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + isEqual( actual, expected ); + + out = new AccessorArray( zeros( ( x.length + 1 )*2, 'generic' ) ); + expected = [ 0, 3, 0, 5, 0, 2, 0, 1 ]; + actual = array2InsertedAt( x, 2, 5, out, -2, out.length-1 ); + + t.strictEqual( actual, out, 'returns expected value' ); + isEqual( actual, expected ); + + t.end(); + + function isEqual( actual, expected ) { + var i; + for ( i = 0; i < expected.length; i++ ) { + t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); + } + } +}); + +tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (array-like)', function test( t ) { + var expected; + var actual; + var out; + var x; + + x = { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + }; + + out = { + 'length': 4, + '0': 0, + '1': 0, + '2': 0, + '3': 0 + }; + expected = [ 5, 1, 2, 3 ]; + actual = array2InsertedAt( x, 0, 5, out, 1, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + isEqual( actual, expected ); + + out = { + 'length': 8, + '0': 0, + '1': 0, + '2': 0, + '3': 0, + '4': 0, + '5': 0, + '6': 0, + '7': 0 + }; + expected = [ 1, 0, 5, 0, 2, 0, 3, 0 ]; + actual = array2InsertedAt( x, 1, 5, out, 2, 0 ); + + t.strictEqual( actual, out, 'returns expected value' ); + isEqual( actual, expected ); + + out = { + 'length': 8, + '0': 0, + '1': 0, + '2': 0, + '3': 0, + '4': 0, + '5': 0, + '6': 0, + '7': 0 + }; + expected = [ 0, 3, 0, 5, 0, 2, 0, 1 ]; + actual = array2InsertedAt( x, 2, 5, out, -2, out.length-1 ); + + t.strictEqual( actual, out, 'returns expected value' ); + isEqual( actual, expected ); + + t.end(); + + function isEqual( actual, expected ) { + var i; + for ( i = 0; i < expected.length; i++ ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } + } +}); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js new file mode 100644 index 000000000000..9a1ce79c0c92 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasMethod = require( '@stdlib/assert/is-method' ); +var array2InsertedAt = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof array2InsertedAt, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( hasOwnProp( array2InsertedAt, 'assign' ), true, 'returns expected value' ); + t.strictEqual( hasMethod( array2InsertedAt, 'assign' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js new file mode 100644 index 000000000000..dda7cafce34e --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js @@ -0,0 +1,401 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var AccessorArray = require( '@stdlib/array/base/accessor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var isArray = require( '@stdlib/assert/is-array' ); +var isFloat64Array = require( '@stdlib/assert/is-float64array' ); +var isInt32Array = require( '@stdlib/assert/is-int32array' ); +var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); +var array2InsertedAt = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof array2InsertedAt, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (generic)', function test( t ) { + var values; + var x; + var i; + + x = [ 1, 2, 3 ]; + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (float64)', function test( t ) { + var values; + var x; + var i; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (int32)', function test( t ) { + var values; + var x; + var i; + + x = new Int32Array( [ 1, 2, 3 ] ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (complex128)', function test( t ) { + var values; + var x; + var i; + + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, new Complex128( 0.0, 0.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (accessors)', function test( t ) { + var values; + var x; + var i; + + x = new AccessorArray( [ 1, 2, 3 ] ); + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is out-of-bounds (array-like)', function test( t ) { + var values; + var x; + var i; + + x = { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + }; + + values = [ + 10, + 100, + 1000, + -10, + -100, + -1000 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + array2InsertedAt( x, value, 0 ); + }; + } +}); + +tape( 'the function returns a new array with an element at a specified index containing a provided value (generic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ 1, 2, 3 ]; + + expected = [ 5, 1, 2, 3 ]; + actual = array2InsertedAt( x, 0, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1, 5, 2, 3 ]; + actual = array2InsertedAt( x, 1, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1, 2, 5, 3 ]; + actual = array2InsertedAt( x, 2, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new array with an element at a specified index containing a provided value (float64)', function test( t ) { + var expected; + var actual; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + expected = [ 5.0, 1.0, 2.0, 3.0 ]; + actual = array2InsertedAt( x, 0, 5.0 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1.0, 5.0, 2.0, 3.0 ]; + actual = array2InsertedAt( x, 1, 5.0 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1.0, 2.0, 5.0, 3.0 ]; + actual = array2InsertedAt( x, 2, 5.0 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new array with an element at a specified index containing a provided value (int32)', function test( t ) { + var expected; + var actual; + var x; + + x = new Int32Array( [ 1, 2, 3 ] ); + + expected = new Int32Array( [ 5, 1, 2, 3 ] ); + actual = array2InsertedAt( x, 0, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = new Int32Array( [ 1, 5, 2, 3 ] ); + actual = array2InsertedAt( x, 1, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = new Int32Array( [ 1, 2, 5, 3 ] ); + actual = array2InsertedAt( x, 2, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new array with an element at a specified index containing a provided value (complex128)', function test( t ) { + var expected; + var actual; + var x; + + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Complex128Array( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + actual = array2InsertedAt( x, 0, new Complex128( 7.0, 8.0 ) ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); + + expected = new Complex128Array( [ 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0 ] ); + actual = array2InsertedAt( x, 1, new Complex128( 7.0, 8.0 ) ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); + + expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 7.0, 8.0, 5.0, 6.0 ] ); + actual = array2InsertedAt( x, 2, new Complex128( 7.0, 8.0 ) ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new array with an element at a specified index containing a provided value (accessors)', function test( t ) { + var expected; + var actual; + var x; + + x = new AccessorArray( [ 1, 2, 3 ] ); + + expected = [ 5, 1, 2, 3 ]; + actual = array2InsertedAt( x, 0, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1, 5, 2, 3 ]; + actual = array2InsertedAt( x, 1, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1, 2, 5, 3 ]; + actual = array2InsertedAt( x, 2, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a new array with an element at a specified index containing a provided value (array-like)', function test( t ) { + var expected; + var actual; + var x; + + x = { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + }; + + expected = [ 5, 1, 2, 3 ]; + actual = array2InsertedAt( x, 0, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1, 5, 2, 3 ]; + actual = array2InsertedAt( x, 1, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ 1, 2, 5, 3 ]; + actual = array2InsertedAt( x, 2, 5 ); + + t.notEqual( actual, x, 'returns different reference' ); + t.strictEqual( isArray( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); From 45fecc31173a1629ac5c704e3a7d02144f8d7e00 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 25 Apr 2025 00:30:53 +0530 Subject: [PATCH 04/18] chore: update benchmark Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../array/base/to-inserted-at/benchmark/benchmark.length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js index d68e98ddca8d..d9bbad1eafd3 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js @@ -54,7 +54,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = array2InsertedAt( x, i%len, i ); - if ( out.length !== len ) { + if ( out.length !== len + 1 ) { b.fail( 'unexpected length' ); } } From 7205464de9ba3f60e5cbb472e64e9c4d1acb3e0e Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 00:33:35 +0530 Subject: [PATCH 05/18] chore: update package.json --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/package.json | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json b/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json index 5af160be3793..8f695f76c6a0 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/package.json @@ -1,64 +1,64 @@ { - "name": "@stdlib/array/base/to-inserted-at", - "version": "0.0.0", - "description": "Return a new array with the element at the specified index inserted with a provided value.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/array/base/to-inserted-at", + "version": "0.0.0", + "description": "Return a new array with the element at the specified index inserted with a provided value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { "name": "The Stdlib Authors", "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "typed", - "collection", - "vector", - "inserted", - "insert", - "inserter", - "copy" - ], - "__stdlib__": {} - } + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "base", + "array", + "typed", + "collection", + "vector", + "inserted", + "insert", + "inserter", + "copy" + ], + "__stdlib__": {} +} From ec6dcd1488ff5b1038faec0448615bbc9c1b905c Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Thu, 24 Apr 2025 19:05:34 +0000 Subject: [PATCH 06/18] chore: update copyright years --- lib/node_modules/@stdlib/array/base/to-inserted-at/README.md | 2 +- .../base/to-inserted-at/benchmark/benchmark.assign.length.js | 2 +- .../array/base/to-inserted-at/benchmark/benchmark.length.js | 2 +- .../@stdlib/array/base/to-inserted-at/docs/types/index.d.ts | 2 +- .../@stdlib/array/base/to-inserted-at/docs/types/test.ts | 2 +- .../@stdlib/array/base/to-inserted-at/examples/index.js | 2 +- .../@stdlib/array/base/to-inserted-at/lib/assign.js | 2 +- lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js | 2 +- lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js | 2 +- .../@stdlib/array/base/to-inserted-at/test/test.assign.js | 2 +- lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js | 2 +- .../@stdlib/array/base/to-inserted-at/test/test.main.js | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md index 0281caf928ae..8d0c9463ecf8 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js index 5fa034a0d0ef..b96b7a59471b 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js index d9bbad1eafd3..ce5eac466017 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts index 8a678213ffbc..992447eba3ee 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts index 1a4f9a8bf151..7f9f00c4b5cc 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js index 5e51cf5c600c..863f58dce7fd 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index 945f3b3ea25e..703b5ef993a3 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js index f696e150756d..11089b0dd2c6 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 9820736ead8a..47da1322624a 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js index b64f175909ce..cc687e3e9b34 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.assign.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js index 9a1ce79c0c92..2fce6b87715f 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js index dda7cafce34e..284df2a6165e 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/test/test.main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 2153a1f07a7e1c0aeee0e69428a1b6b7f8650e1b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 00:39:38 +0530 Subject: [PATCH 07/18] chore: update repl.txt --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/base/to-inserted-at/docs/repl.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt index 8fb21d98a976..e14a2963c6eb 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt @@ -28,14 +28,14 @@ > {{alias}}( x, 0, 5 ) [ 5, 1, 2, 3, 4 ] > {{alias}}( x, -1, 6 ) - [ 1, 2, 3, 4, 6 ] + [ 1, 2, 3, 6, 4 ] > x [ 1, 2, 3, 4 ] {{alias}}.assign( x, index, value, out, stride, offset ) - Copies elements from one array to another array and inserts the element at the - specified index to a provided value. + Copies elements from one array to another array and inserts the element at + the specified index to a provided value. Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. From 341eb6648b8779df242879362f11ad88118cbda3 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 16:02:23 +0530 Subject: [PATCH 08/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/README.md | 20 +-- .../benchmark/benchmark.assign.length.js | 4 +- .../benchmark/benchmark.length.js | 4 +- .../base/to-inserted-at/docs/types/index.d.ts | 30 ++-- .../base/to-inserted-at/docs/types/test.ts | 158 +++++++++--------- .../base/to-inserted-at/examples/index.js | 4 +- .../array/base/to-inserted-at/lib/index.js | 10 +- .../array/base/to-inserted-at/lib/main.js | 10 +- 8 files changed, 120 insertions(+), 120 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md index 8d0c9463ecf8..8bf18705c5d9 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# array2InsertedAt +# toInsertedAt > Return a new array with the element at the specified index inserted with a provided value. @@ -37,20 +37,20 @@ limitations under the License. ## Usage ```javascript -var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +var toInsertedAt = require( '@stdlib/array/base/to-inserted-at' ); ``` -#### array2InsertedAt( x, index, value ) +#### toInsertedAt( x, index, value ) Returns a new array with the element at the specified index inserted with a provided value. ```javascript var x = [ 1, 2, 3, 4 ]; -var out = array2InsertedAt( x, 0, 5 ); +var out = toInsertedAt( x, 0, 5 ); // returns [ 5, 1, 2, 3, 4 ] -out = array2InsertedAt( x, -1, 6 ); +out = toInsertedAt( x, -1, 6 ); // returns [ 1, 2, 3, 6, 4 ] ``` @@ -60,15 +60,15 @@ The function accepts the following arguments: - **index**: element index. - **value**: inserting value. -### array2InsertedAt.assign( x, index, value, out, stride, offset ) +### toInsertedAt.assign( x, index, value, out, stride, offset ) Copies elements from one array to another array and sets the element at the specified index to a provided value. ```javascript var x = [ 1, 2, 3, 4 ]; -var out = [ 0, 0, 0, 0 ]; -var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); +var out = [ 0, 0, 0, 0, 0 ]; +var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); // returns [ 5, 1, 2, 3, 4 ] var bool = ( arr === out ); @@ -111,7 +111,7 @@ The function accepts the following arguments: ```javascript var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +var toInsertedAt = require( '@stdlib/array/base/to-inserted-at' ); // Define an array: var opts = { @@ -128,7 +128,7 @@ var values = discreteUniform( indices.length, -10000, 10000, opts ); // Randomly set elements in the input array: var i; for ( i = 0; i < indices.length; i++ ) { - console.log( 'x = [%s]', array2InsertedAt( x, indices[ i ], values[ i ] ).join( ',' ) ); + console.log( 'x = [%s]', toInsertedAt( x, indices[ i ], values[ i ] ).join( ',' ) ); } ``` diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js index b96b7a59471b..a621ecbb621f 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js @@ -26,7 +26,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var ones = require( '@stdlib/array/base/ones' ); var zeros = require( '@stdlib/array/base/zeros' ); var pkg = require( './../package.json' ).name; -var array2InsertedAt = require( './../lib' ); +var toInsertedAt = require( './../lib' ); // FUNCTIONS // @@ -55,7 +55,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = array2InsertedAt.assign( x, i%len, i, out, 1, 0 ); + v = toInsertedAt.assign( x, i%len, i, out, 1, 0 ); if ( typeof v !== 'object' ) { b.fail( 'should return an array' ); } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js index ce5eac466017..d5d0b2dc54ab 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js @@ -25,7 +25,7 @@ var pow = require( '@stdlib/math/base/special/pow' ); var isArray = require( '@stdlib/assert/is-array' ); var ones = require( '@stdlib/array/base/ones' ); var pkg = require( './../package.json' ).name; -var array2InsertedAt = require( './../lib' ); +var toInsertedAt = require( './../lib' ); // FUNCTIONS // @@ -53,7 +53,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = array2InsertedAt( x, i%len, i ); + out = toInsertedAt( x, i%len, i ); if ( out.length !== len + 1 ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts index 992447eba3ee..1a0d9e5a164f 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts @@ -24,7 +24,7 @@ import { Collection, RealTypedArray, ComplexTypedArray, AccessorArrayLike } from import { ComplexLike } from '@stdlib/types/complex'; /** -* Interface describing `array2InsertedAt`. +* Interface describing `toInsertedAt`. */ interface Array2InsertedAt { /** @@ -41,7 +41,7 @@ interface Array2InsertedAt { * * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * - * var out = array2InsertedAt( x, 0, new Complex128( 7.0, 8.0 ) ); + * var out = toInsertedAt( x, 0, new Complex128( 7.0, 8.0 ) ); * // returns [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] */ ( x: T, index: number, value: ComplexLike ): T; @@ -59,7 +59,7 @@ interface Array2InsertedAt { * * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * - * var out = array2InsertedAt( x, 0, 5.0 ); + * var out = toInsertedAt( x, 0, 5.0 ); * // returns [ 5.0, 1.0, 2.0, 3.0 ] */ ( x: T, index: number, value: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures @@ -75,13 +75,13 @@ interface Array2InsertedAt { * @example * var x = [ 1, 2, 3 ]; * - * var out = array2InsertedAt( x, 0, 7 ); + * var out = toInsertedAt( x, 0, 7 ); * // returns [ 7, 1, 2, 3 ] * * @example * var x = [ 1, 2, 3, 4, 5, 6 ]; * - * var out = array2InsertedAt( x, 1, 8 ); + * var out = toInsertedAt( x, 1, 8 ); * // returns [ 1, 8, 2, 3, 4, 5, 6 ] */ ( x: Collection, index: number, value: T ): Array; @@ -103,7 +103,7 @@ interface Array2InsertedAt { * var x = [ 1, 2, 3, 4 ]; * * var out = new Float64Array( [ 0, 0, 0, 0, 0 ] ); - * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); * // returns [ 5, 1, 2, 3, 4 ] * * var bool = ( arr === out ); @@ -129,7 +129,7 @@ interface Array2InsertedAt { * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * * var out = new Complex128Array( 4 ); - * var arr = array2InsertedAt.assign( x, 0, new Complex128( 7.0, 8.0 ), out, 1, 0 ); + * var arr = toInsertedAt.assign( x, 0, new Complex128( 7.0, 8.0 ), out, 1, 0 ); * // returns [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] * * var bool = ( arr === out ); @@ -152,7 +152,7 @@ interface Array2InsertedAt { * var x = [ 1, 2, 3, 4 ]; * * var out = [ 0, 0, 0, 0, 0 ]; - * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); * // returns [ 5, 1, 2, 3, 4 ] * * var bool = ( arr === out ); @@ -177,7 +177,7 @@ interface Array2InsertedAt { * var x = toAccessorArray( [ 1, 2, 3, 4 ] ); * * var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); * * var v = out[ 0 ]; * // returns 5 @@ -202,7 +202,7 @@ interface Array2InsertedAt { * var x = [ 1, 2, 3, 4 ]; * * var out = [ 0, 0, 0, 0, 0 ]; - * var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); + * var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); * // returns [ 5, 1, 2, 3, 4 ] * * var bool = ( arr === out ); @@ -222,13 +222,13 @@ interface Array2InsertedAt { * @example * var x = [ 1, 2, 3 ]; * -* var out = array2InsertedAt( x, 0, 7 ); +* var out = toInsertedAt( x, 0, 7 ); * // returns [ 7, 1, 2, 3 ] * * @example * var x = [ 1, 2, 3, 4, 5, 6 ]; * -* var out = array2InsertedAt( x, 1, 8 ); +* var out = toInsertedAt( x, 1, 8 ); * // returns [ 1, 8, 2, 3, 4, 5, 6 ] * * @example @@ -237,15 +237,15 @@ interface Array2InsertedAt { * var x = [ 1, 2, 3, 4 ]; * * var out = new Float64Array( [ 0, 0, 0, 0, 0 ] ); -* var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); +* var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); * // returns [ 5, 1, 2, 3, 4 ] * * var bool = ( arr === out ); * // returns true */ -declare var array2InsertedAt: Array2InsertedAt; +declare var toInsertedAt: Array2InsertedAt; // EXPORTS // -export = array2InsertedAt; +export = toInsertedAt; diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts index 7f9f00c4b5cc..779968b2ea2e 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/test.ts @@ -19,52 +19,52 @@ import Complex128Array = require( '@stdlib/array/complex128' ); import Complex64Array = require( '@stdlib/array/complex64' ); import toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -import array2InsertedAt = require( './index' ); +import toInsertedAt = require( './index' ); // TESTS // // The function returns an updated array... { - array2InsertedAt( [ 1, 2, 3, 4 ], 0, 5 ); // $ExpectType number[] - array2InsertedAt( new Complex128Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex128Array - array2InsertedAt( new Complex64Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex64Array - array2InsertedAt( toAccessorArray( [ 1, 2, 3, 4 ] ), 0, 5 ); // $ExpectType number[] + toInsertedAt( [ 1, 2, 3, 4 ], 0, 5 ); // $ExpectType number[] + toInsertedAt( new Complex128Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex128Array + toInsertedAt( new Complex64Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex64Array + toInsertedAt( toAccessorArray( [ 1, 2, 3, 4 ] ), 0, 5 ); // $ExpectType number[] } // The compiler throws an error if the function is provided a first argument which is not a collection... { - array2InsertedAt( 5, 0, 5 ); // $ExpectError - array2InsertedAt( true, 0, 5 ); // $ExpectError - array2InsertedAt( false, 0, 5 ); // $ExpectError - array2InsertedAt( null, 0, 5 ); // $ExpectError - array2InsertedAt( void 0, 0, 5 ); // $ExpectError - array2InsertedAt( {}, 0, 5 ); // $ExpectError - array2InsertedAt( ( x: number ): number => x, 0, 5 ); // $ExpectError + toInsertedAt( 5, 0, 5 ); // $ExpectError + toInsertedAt( true, 0, 5 ); // $ExpectError + toInsertedAt( false, 0, 5 ); // $ExpectError + toInsertedAt( null, 0, 5 ); // $ExpectError + toInsertedAt( void 0, 0, 5 ); // $ExpectError + toInsertedAt( {}, 0, 5 ); // $ExpectError + toInsertedAt( ( x: number ): number => x, 0, 5 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... { const x = [ 1, 2, 3, 4 ]; - array2InsertedAt( x, 'abc', 5 ); // $ExpectError - array2InsertedAt( x, true, 5 ); // $ExpectError - array2InsertedAt( x, false, 5 ); // $ExpectError - array2InsertedAt( x, null, 5 ); // $ExpectError - array2InsertedAt( x, void 0, 5 ); // $ExpectError - array2InsertedAt( x, [ '1' ], 5 ); // $ExpectError - array2InsertedAt( x, {}, 5 ); // $ExpectError - array2InsertedAt( x, ( x: number ): number => x, 5 ); // $ExpectError + toInsertedAt( x, 'abc', 5 ); // $ExpectError + toInsertedAt( x, true, 5 ); // $ExpectError + toInsertedAt( x, false, 5 ); // $ExpectError + toInsertedAt( x, null, 5 ); // $ExpectError + toInsertedAt( x, void 0, 5 ); // $ExpectError + toInsertedAt( x, [ '1' ], 5 ); // $ExpectError + toInsertedAt( x, {}, 5 ); // $ExpectError + toInsertedAt( x, ( x: number ): number => x, 5 ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const x = [ 1, 2, 3, 4 ]; - array2InsertedAt(); // $ExpectError - array2InsertedAt( x ); // $ExpectError - array2InsertedAt( x, 0 ); // $ExpectError - array2InsertedAt( x, 0, 0, 5 ); // $ExpectError + toInsertedAt(); // $ExpectError + toInsertedAt( x ); // $ExpectError + toInsertedAt( x, 0 ); // $ExpectError + toInsertedAt( x, 0, 0, 5 ); // $ExpectError } // Attached to the main export is an `assign` method which returns a collection... @@ -72,30 +72,30 @@ import array2InsertedAt = require( './index' ); const x = [ 1, 2, 3, 4 ]; const y = new Complex128Array( 4 ); - array2InsertedAt.assign( x, 0, 5, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] - array2InsertedAt.assign( x, 0, 5, new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array - array2InsertedAt.assign( x, 0, 5, new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array - array2InsertedAt.assign( x, 0, 5, new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array - array2InsertedAt.assign( x, 0, 5, new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array - array2InsertedAt.assign( x, 0, 5, new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array - array2InsertedAt.assign( x, 0, 5, new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array - array2InsertedAt.assign( x, 0, 5, new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array - array2InsertedAt.assign( x, 0, 5, new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array - array2InsertedAt.assign( x, 0, 5, new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray - array2InsertedAt.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array - array2InsertedAt.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array + toInsertedAt.assign( x, 0, 5, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] + toInsertedAt.assign( x, 0, 5, new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array + toInsertedAt.assign( x, 0, 5, new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array + toInsertedAt.assign( x, 0, 5, new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array + toInsertedAt.assign( x, 0, 5, new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array + toInsertedAt.assign( x, 0, 5, new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array + toInsertedAt.assign( x, 0, 5, new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array + toInsertedAt.assign( x, 0, 5, new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array + toInsertedAt.assign( x, 0, 5, new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array + toInsertedAt.assign( x, 0, 5, new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray + toInsertedAt.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array + toInsertedAt.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array } // The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... { const out = [ 0, 0, 0, 0 ]; - array2InsertedAt.assign( 1, 0, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( true, 0, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( false, 0, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( null, 0, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( void 0, 0, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( {}, 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( 1, 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( true, 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( false, 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( null, 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( void 0, 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( {}, 0, 5, out, 1, 0 ); // $ExpectError } // The compiler throws an error if the `assign` method is provided a second argument which is not a number... @@ -103,27 +103,27 @@ import array2InsertedAt = require( './index' ); const x = [ 1, 2, 3, 4 ]; const out = [ 0, 0, 0, 0 ]; - array2InsertedAt.assign( x, '1', 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, true, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, false, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, null, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, void 0, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, [], 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, {}, 5, out, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, ( x: number ): number => x, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, '1', 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, true, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, false, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, null, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, void 0, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, [], 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, {}, 5, out, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, ( x: number ): number => x, 5, out, 1, 0 ); // $ExpectError } // The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... { const x = [ 1, 2, 3, 4 ]; - array2InsertedAt.assign( x, 0, 5, 1, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 5, true, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 5, false, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 5, null, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 5, void 0, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 5, {}, 1, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 5, ( x: number ): number => x, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, 1, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, true, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, false, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, null, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, void 0, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, {}, 1, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 5, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... @@ -131,14 +131,14 @@ import array2InsertedAt = require( './index' ); const x = [ 1, 2, 3, 4 ]; const out = [ 0, 0, 0, 0 ]; - array2InsertedAt.assign( x, 0, 1, out, '1', 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, true, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, false, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, null, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, void 0, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, [], 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, {}, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, ( x: number ): number => x, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, '1', 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, true, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, false, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, null, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, void 0, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, [], 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, {}, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... @@ -146,14 +146,14 @@ import array2InsertedAt = require( './index' ); const x = [ 1, 2, 3, 4 ]; const out = [ 0, 0, 0, 0 ]; - array2InsertedAt.assign( x, 0, 1, out, 1, '1' ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, true ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, false ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, null ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, void 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, [] ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, {} ); // $ExpectError - array2InsertedAt.assign( x, 0, 1, out, 1, ( x: number ): number => x ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, '1' ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, true ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, false ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, null ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, void 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, [] ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, {} ); // $ExpectError + toInsertedAt.assign( x, 0, 1, out, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `assign` method is provided an unsupported number of arguments... @@ -161,10 +161,10 @@ import array2InsertedAt = require( './index' ); const x = [ 1, 2, 3, 4 ]; const out = [ 0, 0, 0, 0 ]; - array2InsertedAt.assign(); // $ExpectError - array2InsertedAt.assign( x ); // $ExpectError - array2InsertedAt.assign( x, 0 ); // $ExpectError - array2InsertedAt.assign( x, 0, 0, out ); // $ExpectError - array2InsertedAt.assign( x, 0, 0, out, 1 ); // $ExpectError - array2InsertedAt.assign( x, 0, 0, out, 1, 0, {} ); // $ExpectError + toInsertedAt.assign(); // $ExpectError + toInsertedAt.assign( x ); // $ExpectError + toInsertedAt.assign( x, 0 ); // $ExpectError + toInsertedAt.assign( x, 0, 0, out ); // $ExpectError + toInsertedAt.assign( x, 0, 0, out, 1 ); // $ExpectError + toInsertedAt.assign( x, 0, 0, out, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js index 863f58dce7fd..545db386cc07 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/examples/index.js @@ -19,7 +19,7 @@ 'use strict'; var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var array2InsertedAt = require( './../lib' ); +var toInsertedAt = require( './../lib' ); // Define an array: var opts = { @@ -36,5 +36,5 @@ var values = discreteUniform( indices.length, -10000, 10000, opts ); // Randomly set elements in the input array: var i; for ( i = 0; i < indices.length; i++ ) { - console.log( 'x = [%s]', array2InsertedAt( x, indices[ i ], values[ i ] ).join( ',' ) ); + console.log( 'x = [%s]', toInsertedAt( x, indices[ i ], values[ i ] ).join( ',' ) ); } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js index 11089b0dd2c6..36fad16d72f6 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js @@ -24,23 +24,23 @@ * @module @stdlib/array/base/to-inserted-at * * @example -* var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +* var toInsertedAt = require( '@stdlib/array/base/to-inserted-at' ); * * var x = [ 1, 2, 3, 4 ]; * -* var v = array2InsertedAt( x, 0, 5 ); +* var v = toInsertedAt( x, 0, 5 ); * // returns [ 5, 1, 2, 3, 4 ] * -* v = array2InsertedAt( x, -2, -1 ); +* v = toInsertedAt( x, -2, -1 ); * // returns [ 1, 2, 3, -1, 4 ] * * @example -* var array2InsertedAt = require( '@stdlib/array/base/to-inserted-at' ); +* var toInsertedAt = require( '@stdlib/array/base/to-inserted-at' ); * * var x = [ 1, 2, 3, 4 ]; * * var out = [ 0, 0, 0, 0 ]; -* var arr = array2InsertedAt.assign( x, 0, 5, out, 1, 0 ); +* var arr = toInsertedAt.assign( x, 0, 5, out, 1, 0 ); * // returns [ 5, 1, 2, 3, 4 ] * * var bool = ( arr === out ); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 47da1322624a..9c393c29d4ab 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -41,16 +41,16 @@ var assign = require( './assign.js' ); * @example * var x = [ 1, 2, 3, 4 ]; * -* var v = array2InsertedAt( x, 0, 5 ); +* var v = toInsertedAt( x, 0, 5 ); * // returns [ 5, 1, 2, 3, 4 ] * -* v = array2InsertedAt( x, 1, 6 ); +* v = toInsertedAt( x, 1, 6 ); * // returns [ 1, 6, 2, 3, 4 ] * -* v = array2InsertedAt( x, -2, 7 ); +* v = toInsertedAt( x, -2, 7 ); * // returns [ 1, 2, 7, 3, 4 ] */ -function array2InsertedAt( x, index, value ) { +function toInsertedAt( x, index, value ) { var out; index = normalizeIndex( index, x.length-1 ); @@ -65,4 +65,4 @@ function array2InsertedAt( x, index, value ) { // EXPORTS // -module.exports = array2InsertedAt; +module.exports = toInsertedAt; From c22c0f55f122f7f640e9db44e82693d74f4a4d03 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 16:08:17 +0530 Subject: [PATCH 09/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/docs/repl.txt | 4 ++-- .../base/to-inserted-at/docs/types/index.d.ts | 18 +++++++++--------- .../array/base/to-inserted-at/lib/assign.js | 8 ++++---- .../array/base/to-inserted-at/lib/main.js | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt index e14a2963c6eb..97a9b8396637 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt @@ -15,7 +15,7 @@ Index of the element to be inserted. value: any - Inserting value. + Value to insert. Returns ------- @@ -49,7 +49,7 @@ Index of the element to be inserted. value: any - Inserting value. + Value to insert. out: ArrayLikeObject Output array. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts index 1a0d9e5a164f..c69d16bde7dd 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts @@ -32,7 +32,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @returns output array * * @example @@ -51,7 +51,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @returns output array * * @example @@ -69,7 +69,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @returns output array * * @example @@ -91,7 +91,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @param out - output array * @param stride - output array stride * @param offset - output array offset @@ -116,7 +116,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @param out - output array * @param stride - output array stride * @param offset - output array offset @@ -142,7 +142,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @param out - output array * @param stride - output array stride * @param offset - output array offset @@ -165,7 +165,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @param out - output array * @param stride - output array stride * @param offset - output array offset @@ -192,7 +192,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value - * @param value - inserting value + * @param value - value to insert * @param out - output array * @param stride - output array stride * @param offset - output array offset @@ -216,7 +216,7 @@ interface Array2InsertedAt { * * @param x - input array * @param index - index at which to set a provided value -* @param value - inserting value +* @param value - value to insert * @returns output array * * @example diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index 703b5ef993a3..b74c1a47ac8a 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -41,7 +41,7 @@ var format = require( '@stdlib/string/format' ); * @private * @param {Collection} x - input array * @param {integer} index - element index -* @param {*} value - inserting value +* @param {*} value - value to insert * @param {Collection} out - output array * @param {integer} stride - output array stride * @param {NonNegativeInteger} offset - output array offset @@ -80,7 +80,7 @@ function indexed( x, index, value, out, stride, offset ) { * @private * @param {Object} x - input array object * @param {integer} index - element index -* @param {*} value - inserting value +* @param {*} value - value to insert * @param {Object} out - output array object * @param {integer} stride - output array stride * @param {NonNegativeInteger} offset - output array offset @@ -133,7 +133,7 @@ function accessors( x, index, value, out, stride, offset ) { * @private * @param {Collection} x - real-valued floating-point input array view * @param {integer} index - element index -* @param {ComplexLike} value - inserting value +* @param {ComplexLike} value - value to insert * @param {Collection} out - real-valued floating-point output array view * @param {integer} stride - output array stride * @param {NonNegativeInteger} offset - output array offset @@ -179,7 +179,7 @@ function complex( x, index, value, out, stride, offset ) { * * @param {Collection} x - input array * @param {integer} index - element index -* @param {*} value - inserting value +* @param {*} value - value to insert * @param {Collection} out - output array * @param {integer} stride - output array stride * @param {NonNegativeInteger} offset - output array offset diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 9c393c29d4ab..97af4cecedef 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -34,7 +34,7 @@ var assign = require( './assign.js' ); * * @param {Collection} x - input array * @param {integer} index - element index -* @param {*} value - inserting value +* @param {*} value - value to insert * @throws {RangeError} second argument must not exceed array bounds * @returns {Collection} output array * From 128a273523637986266ba89383dd815d0044f27e Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 16:10:37 +0530 Subject: [PATCH 10/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/base/to-inserted-at/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md index 8bf18705c5d9..37513c14d34f 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md @@ -58,7 +58,7 @@ The function accepts the following arguments: - **x**: an input array. - **index**: element index. -- **value**: inserting value. +- **value**: value to insert. ### toInsertedAt.assign( x, index, value, out, stride, offset ) @@ -79,7 +79,7 @@ The function accepts the following arguments: - **x**: an input array. - **index**: element index. -- **value**: inserting value. +- **value**: value to insert. - **out**: output array. - **stride**: output array stride. - **offset**: output array offset. @@ -96,7 +96,6 @@ The function accepts the following arguments: - Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. - From ae6c33fa325d18e3b4f6f2080bcfb54d41d83001 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 16:18:00 +0530 Subject: [PATCH 11/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/base/to-inserted-at/README.md | 4 ++-- .../@stdlib/array/base/to-inserted-at/docs/repl.txt | 8 ++++---- .../array/base/to-inserted-at/docs/types/index.d.ts | 8 ++++---- .../@stdlib/array/base/to-inserted-at/lib/assign.js | 8 ++++---- .../@stdlib/array/base/to-inserted-at/lib/index.js | 2 +- .../@stdlib/array/base/to-inserted-at/lib/main.js | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md index 37513c14d34f..2ba87460e8f5 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md @@ -20,7 +20,7 @@ limitations under the License. # toInsertedAt -> Return a new array with the element at the specified index inserted with a provided value. +> Return a new array containing every element from an input array, with a provided value inserted at a specified index. @@ -42,7 +42,7 @@ var toInsertedAt = require( '@stdlib/array/base/to-inserted-at' ); #### toInsertedAt( x, index, value ) -Returns a new array with the element at the specified index inserted with a provided value. +Returns a new array containing every element from an input array, with a provided value inserted at a specified index. ```javascript var x = [ 1, 2, 3, 4 ]; diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt index 97a9b8396637..a954b53912a8 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( x, index, value ) - Returns a new array with the element at the specified index inserted with a - provided value. + Returns a new array containing every element from an input array, with a + provided value inserted at a specified index. Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. @@ -34,8 +34,8 @@ {{alias}}.assign( x, index, value, out, stride, offset ) - Copies elements from one array to another array and inserts the element at - the specified index to a provided value. + Copies elements from one array to another array and with a provided value + inserted at a specified index. Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts index c69d16bde7dd..8dcf69c29794 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/types/index.d.ts @@ -28,7 +28,7 @@ import { ComplexLike } from '@stdlib/types/complex'; */ interface Array2InsertedAt { /** - * Returns a new array with the element at the specified index inserted with a provided value. + * Returns a new array containing every element from an input array, with a provided value inserted at a specified index. * * @param x - input array * @param index - index at which to set a provided value @@ -47,7 +47,7 @@ interface Array2InsertedAt { ( x: T, index: number, value: ComplexLike ): T; /** - * Returns a new array with the element at the specified index inserted with a provided value. + * Returns a new array containing every element from an input array, with a provided value inserted at a specified index. * * @param x - input array * @param index - index at which to set a provided value @@ -65,7 +65,7 @@ interface Array2InsertedAt { ( x: T, index: number, value: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures /** - * Returns a new array with the element at the specified index inserted with a provided value. + * Returns a new array containing every element from an input array, with a provided value inserted at a specified index. * * @param x - input array * @param index - index at which to set a provided value @@ -212,7 +212,7 @@ interface Array2InsertedAt { } /** -* Returns a new array with the element at the specified index inserted with a provided value. +* Returns a new array containing every element from an input array, with a provided value inserted at a specified index. * * @param x - input array * @param index - index at which to set a provided value diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index b74c1a47ac8a..3b784543abf8 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -36,7 +36,7 @@ var format = require( '@stdlib/string/format' ); // FUNCTIONS // /** -* Copies elements from one array to another array and inserts the element at the specified index to a provided value. +* Copies elements from one array to another array and with a provided value inserted at a specified index. * * @private * @param {Collection} x - input array @@ -75,7 +75,7 @@ function indexed( x, index, value, out, stride, offset ) { } /** -* Copies elements from one accessor array to another accessor array and inserts the element at the specified index to a provided value. +* Copies elements from one accessor array to another accessor array and with a provided value inserted at a specified index. * * @private * @param {Object} x - input array object @@ -128,7 +128,7 @@ function accessors( x, index, value, out, stride, offset ) { } /** -* Copies elements from one complex array to another complex array and inserts the element at the specified index to a provided value. +* Copies elements from one complex array to another complex array and with a provided value inserted at a specified index. * * @private * @param {Collection} x - real-valued floating-point input array view @@ -175,7 +175,7 @@ function complex( x, index, value, out, stride, offset ) { // MAIN // /** -* Copies elements from one array to another array and inserts the element at the specified index to a provided value. +* Copies elements from one array to another array and with a provided value inserted at a specified index. * * @param {Collection} x - input array * @param {integer} index - element index diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js index 36fad16d72f6..e703a37f5d78 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return a new array with the element at the specified index inserted with a provided value. +* Return a new array containing every element from an input array, with a provided value inserted at a specified index. * * @module @stdlib/array/base/to-inserted-at * diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 97af4cecedef..6b8de5f3ffa1 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -30,7 +30,7 @@ var assign = require( './assign.js' ); // MAIN // /** -* Returns a new array with the element at the specified index inserted with a provided value. +* Returns a new array containing every element from an input array, with a provided value inserted at a specified index. * * @param {Collection} x - input array * @param {integer} index - element index From 641df0f8352bb30327d80bec6cc31dee998b731b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 16:52:50 +0530 Subject: [PATCH 12/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/lib/assign.js | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index 3b784543abf8..539376d103f8 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -58,6 +58,9 @@ var format = require( '@stdlib/string/format' ); * // returns true */ function indexed( x, index, value, out, stride, offset ) { + var idx1; + var idxo; + var idx; var io; var i; @@ -67,9 +70,12 @@ function indexed( x, index, value, out, stride, offset ) { io += stride; } for ( i = x.length - 1; i >= index; i-- ) { - out[ offset + ((i + 1) * stride) ] = out[ offset + (i * stride) ]; + idx1 = offset + ( ( i + 1 ) * stride ); + idx = offset + ( i * stride ); + out[ idx1 ] = out[ idx ]; } - out[ offset + (index * stride) ] = value; + idxo = offset + ( index * stride ); + out[ idxo ] = value; return out; } @@ -101,9 +107,12 @@ function indexed( x, index, value, out, stride, offset ) { function accessors( x, index, value, out, stride, offset ) { var xdata; var odata; + var idx1; + var idxo; var xget; var oget; var oset; + var idx; var io; var i; @@ -120,10 +129,13 @@ function accessors( x, index, value, out, stride, offset ) { io += stride; } for ( i = xdata.length - 1; i >= index; i-- ) { - oset( odata, offset + ((i + 1) * stride), oget( odata, offset + (i * stride) ) ); + idx1 = offset + ( ( i + 1 ) * stride ); + idx = offset + ( i * stride ); + oset( odata, idx1, oget( odata, idx ) ); } - oset( odata, offset + (index * stride), value ); + idxo = offset + ( index * stride ); + oset( odata, idxo, value ); return odata; } @@ -151,22 +163,31 @@ function accessors( x, index, value, out, stride, offset ) { * // returns [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] */ function complex( x, index, value, out, stride, offset ) { + var idx1; + var idxo; + var idx; var so; var io; var i; + var j; so = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components io = offset * 2; for ( i = 0; i < x.length/2; i++ ) { - out[ io + ( i * so ) ] = x[ 2 * i ]; - out[ io + ( i * so ) + 1 ] = x[ ( 2 * i ) + 1 ]; + idx = io + ( i * so ); + j = i * 2; + out[ idx ] = x[ j ]; + out[ idx + 1 ] = x[ j + 1 ]; } for ( i = ( x.length/2 ) - 1; i >= index; i-- ) { - out[ io + ( ( i + 1 ) * so ) ] = out[ io + ( i * so ) ]; - out[ ( io + ( ( i + 1 ) * so ) ) + 1] = out[ io + ( i * so ) + 1]; + idx1 = io + ( ( i + 1 ) * so ); + idx = io + ( i * so ); + out[ idx1 ] = out[ idx ]; + out[ idx1 + 1 ] = out[ idx + 1 ]; } - out[ io + ( index * so ) ] = real( value ); - out[ io + ( index * so ) + 1] = imag( value ); + idxo = io + ( index * so ); + out[ idxo ] = real( value ); + out[ idxo + 1 ] = imag( value ); return out; } From f9bd4d6296838e619c29bdf7064d61ce31acca06 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 17:19:11 +0530 Subject: [PATCH 13/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/to-inserted-at/lib/assign.js | 81 ++++++++----------- 1 file changed, 34 insertions(+), 47 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index 539376d103f8..4f1d77808c79 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -58,25 +58,22 @@ var format = require( '@stdlib/string/format' ); * // returns true */ function indexed( x, index, value, out, stride, offset ) { - var idx1; - var idxo; - var idx; var io; var i; + var j; io = offset; - for ( i = 0; i < x.length; i++ ) { - out[ io ] = x[ i ]; - io += stride; - } - for ( i = x.length - 1; i >= index; i-- ) { - idx1 = offset + ( ( i + 1 ) * stride ); - idx = offset + ( i * stride ); - out[ idx1 ] = out[ idx ]; + j = 0; + for ( i = 0; i < x.length + 1; i++ ) { + if ( i === index ) { + out[ io ] = value; + io += stride; + } else { + out[ io ] = x[ j ]; + io += stride; + j += 1; + } } - idxo = offset + ( index * stride ); - out[ idxo ] = value; - return out; } @@ -107,35 +104,31 @@ function indexed( x, index, value, out, stride, offset ) { function accessors( x, index, value, out, stride, offset ) { var xdata; var odata; - var idx1; - var idxo; var xget; - var oget; var oset; - var idx; var io; var i; + var j; xdata = x.data; odata = out.data; xget = x.accessors[ 0 ]; - oget = out.accessors[ 0 ]; oset = out.accessors[ 1 ]; io = offset; - for ( i = 0; i < xdata.length; i++ ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - for ( i = xdata.length - 1; i >= index; i-- ) { - idx1 = offset + ( ( i + 1 ) * stride ); - idx = offset + ( i * stride ); - oset( odata, idx1, oget( odata, idx ) ); + j = 0; + for ( i = 0; i < xdata.length + 1; i++ ) { + if ( i === index ) { + oset( odata, io, value ); + io += stride; + } else { + oset( odata, io, xget( xdata, j ) ); + io += stride; + j += 1; + } } - idxo = offset + ( index * stride ); - oset( odata, idxo, value ); return odata; } @@ -163,9 +156,6 @@ function accessors( x, index, value, out, stride, offset ) { * // returns [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] */ function complex( x, index, value, out, stride, offset ) { - var idx1; - var idxo; - var idx; var so; var io; var i; @@ -173,22 +163,19 @@ function complex( x, index, value, out, stride, offset ) { so = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components io = offset * 2; - for ( i = 0; i < x.length/2; i++ ) { - idx = io + ( i * so ); - j = i * 2; - out[ idx ] = x[ j ]; - out[ idx + 1 ] = x[ j + 1 ]; - } - for ( i = ( x.length/2 ) - 1; i >= index; i-- ) { - idx1 = io + ( ( i + 1 ) * so ); - idx = io + ( i * so ); - out[ idx1 ] = out[ idx ]; - out[ idx1 + 1 ] = out[ idx + 1 ]; + j = 0; + for ( i = 0; i < ( x.length + 1 ) / 2; i++ ) { + if ( i === index ) { + out[ io ] = real( value ); + out[ io + 1 ] = imag( value ); + io += so; + } else { + out[ io ] = x[ j ]; + out[ io + 1 ] = x[ j + 1 ]; + io += so; + j += 2; + } } - idxo = io + ( index * so ); - out[ idxo ] = real( value ); - out[ idxo + 1 ] = imag( value ); - return out; } From 94fb9ce056cffda9823d0abf23e28360735b19b0 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 25 Apr 2025 17:29:18 +0530 Subject: [PATCH 14/18] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../to-inserted-at/benchmark/benchmark.assign.length.js | 6 ++++-- .../array/base/to-inserted-at/benchmark/benchmark.length.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js index a621ecbb621f..bfae3a659636 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.assign.length.js @@ -39,8 +39,6 @@ var toInsertedAt = require( './../lib' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var out = zeros( len ); - var x = ones( len ); return benchmark; /** @@ -50,11 +48,15 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { + var out; var v; + var x; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { + x = ones( len ); + out = zeros( len ); v = toInsertedAt.assign( x, i%len, i, out, 1, 0 ); if ( typeof v !== 'object' ) { b.fail( 'should return an array' ); diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js index d5d0b2dc54ab..c0631b9af309 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/benchmark/benchmark.length.js @@ -38,7 +38,6 @@ var toInsertedAt = require( './../lib' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = ones( len ); return benchmark; /** @@ -49,10 +48,12 @@ function createBenchmark( len ) { */ function benchmark( b ) { var out; + var x; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { + x = ones( len ); out = toInsertedAt( x, i%len, i ); if ( out.length !== len + 1 ) { b.fail( 'unexpected length' ); From 609d9e92702aeda8671d6446340abbcd55d68afb Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:54:35 +0530 Subject: [PATCH 15/18] fix: indexing Co-authored-by: Athan Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 6b8de5f3ffa1..1d6538111210 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -53,7 +53,7 @@ var assign = require( './assign.js' ); function toInsertedAt( x, index, value ) { var out; - index = normalizeIndex( index, x.length-1 ); + index = normalizeIndex( index, x.length ); if ( index < 0 ) { throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); } From d8308629af35e8b4b15b9c3b1571e9520c2b4520 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 30 Apr 2025 19:18:28 +0530 Subject: [PATCH 16/18] chore: update jsdoc --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/base/to-inserted-at/lib/assign.js | 2 +- lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js index 4f1d77808c79..f6a2dd38819a 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/assign.js @@ -208,7 +208,7 @@ function assign( x, index, value, out, stride, offset ) { var xo; var oo; - index = normalizeIndex( index, x.length-1 ); + index = normalizeIndex( index, x.length ); if ( index < 0 ) { throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); } diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js index 1d6538111210..493839822e31 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/lib/main.js @@ -48,7 +48,7 @@ var assign = require( './assign.js' ); * // returns [ 1, 6, 2, 3, 4 ] * * v = toInsertedAt( x, -2, 7 ); -* // returns [ 1, 2, 7, 3, 4 ] +* // returns [ 1, 2, 3, 7, 4 ] */ function toInsertedAt( x, index, value ) { var out; From d3d06cf3128cc8bd9387fdb3d73436272342225f Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 30 Apr 2025 19:23:56 +0530 Subject: [PATCH 17/18] chore: update examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/base/to-inserted-at/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md index 2ba87460e8f5..13b8a01fda7a 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/README.md @@ -51,7 +51,7 @@ var out = toInsertedAt( x, 0, 5 ); // returns [ 5, 1, 2, 3, 4 ] out = toInsertedAt( x, -1, 6 ); -// returns [ 1, 2, 3, 6, 4 ] +// returns [ 1, 2, 3, 4, 6 ] ``` The function accepts the following arguments: From 4e27cee0511dcd963c4b8997560a9ced507635f8 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 30 Apr 2025 19:28:23 +0530 Subject: [PATCH 18/18] chore: update examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/base/to-inserted-at/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt index a954b53912a8..a20df8934378 100644 --- a/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/base/to-inserted-at/docs/repl.txt @@ -28,7 +28,7 @@ > {{alias}}( x, 0, 5 ) [ 5, 1, 2, 3, 4 ] > {{alias}}( x, -1, 6 ) - [ 1, 2, 3, 6, 4 ] + [ 1, 2, 3, 4, 6 ] > x [ 1, 2, 3, 4 ]