/* * @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, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; /** * Returns a boolean indicating whether an element passes a test. * * @returns boolean indicating whether an element passes a test */ type Nullary = ( this: U ) => boolean; /** * Returns a boolean indicating whether an element passes a test. * * @param value - current array element * @returns boolean indicating whether an element passes a test */ type Unary = ( this: U, value: T ) => boolean; /** * Returns a boolean indicating whether an element passes a test. * * @param value - current array element * @param index - current array element index * @returns boolean indicating whether an element passes a test */ type Binary = ( this: U, value: T, index: number ) => boolean; /** * Returns a boolean indicating whether an element passes a test. * * @param value - current array element * @param index - current array element index * @param arr - input array * @returns boolean indicating whether an element passes a test */ type Ternary = ( this: U, value: T, index: number, arr: V ) => boolean; /** * Returns a boolean indicating whether an element passes a test. * * @param value - current array element * @param index - current array element index * @param arr - input array * @returns boolean indicating whether an element passes a test */ type Predicate = Nullary | Unary | Binary | Ternary; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Float64Array = require( '@stdlib/array/float64' ); * * var x = new Float64Array( [ 1.0, -2.0, -3.0, 4.0 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ -2.0, -3.0 ] */ declare function reject( x: Float64Array, predicate: Predicate, thisArg?: ThisParameterType> ): Float64Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, -3.0, 4.0 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ -2.0, -3.0 ] */ declare function reject( x: Float32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Float32Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Int32Array = require( '@stdlib/array/int32' ); * * var x = new Int32Array( [ 1, -2, -3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ -2, -3 ] */ declare function reject( x: Int32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int32Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Int16Array = require( '@stdlib/array/int16' ); * * var x = new Int16Array( [ 1, -2, -3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ -2, -3 ] */ declare function reject( x: Int16Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int16Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Int8Array = require( '@stdlib/array/int8' ); * * var x = new Int8Array( [ 1, -2, -3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ -2, -3 ] */ declare function reject( x: Int8Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int8Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Uint32Array = require( '@stdlib/array/uint32' ); * * var x = new Uint32Array( [ 0, 1, 2, 3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ 0 ] */ declare function reject( x: Uint32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint32Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Uint16Array = require( '@stdlib/array/uint16' ); * * var x = new Uint16Array( [ 0, 1, 2, 3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ 0 ] */ declare function reject( x: Uint16Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint16Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Uint8Array = require( '@stdlib/array/uint8' ); * * var x = new Uint8Array( [ 0, 1, 2, 3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ 0 ] */ declare function reject( x: Uint8Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint8Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); * * var x = new Uint8ClampedArray( [ 0, 1, 2, 3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ 0 ] */ declare function reject( x: Uint8ClampedArray, predicate: Predicate, thisArg?: ThisParameterType> ): Uint8ClampedArray; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); * var Complex128Array = require( '@stdlib/array/complex128' ); * * function predicate( v ) { * return ( isPositiveNumber( real( v ) ) && isPositiveNumber( imag( v ) ) ); * } * * var x = new Complex128Array( [ 1.0, -2.0, 3.0, 4.0 ] ); * * var out = reject( x, predicate ); * // returns */ declare function reject( x: Complex128Array, predicate: Predicate, thisArg?: ThisParameterType> ): Complex128Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * * function predicate( v ) { * return ( isPositiveNumber( realf( v ) ) && isPositiveNumber( imagf( v ) ) ); * } * * var x = new Complex64Array( [ 1.0, -2.0, 3.0, 4.0 ] ); * * var out = reject( x, predicate ); * // returns */ declare function reject( x: Complex64Array, predicate: Predicate, thisArg?: ThisParameterType> ): Complex64Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var x = [ 1, -2, -3, 4 ]; * * var out = reject( x, isPositiveNumber ); * // returns [ -2, -3 ] */ declare function reject( x: Array, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * * var x = toAccessorArray( [ 1, -2, -3, 4 ] ); * * var out = reject( x, isPositiveNumber ); * // returns [ -2, -3 ] */ declare function reject( x: AccessorArrayLike, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; /** * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. * * @param x - input array * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output array * * @example * var x = [ 1, -2, -3, 4 ]; * * var out = reject( x, isPositiveNumber ); * // returns [ -2, -3 ] */ declare function reject( x: Collection, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; // EXPORTS // export = reject;