Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stdlib/array-base-assert-is-accessor-array

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/array-base-assert-is-accessor-array - npm Package Compare versions

Comparing version
0.0.1
to
0.1.0
CITATION.cff

Sorry, the diff of this file is not supported yet

+3
/// <reference path="../docs/types/index.d.ts" />
import isAccessorArray from '../docs/types/index';
export = isAccessorArray;
"use strict";var o=function(r,t){return function(){return t||r((t={exports:{}}).exports,t),t.exports}};var i=o(function(f,s){
var e="function";function c(r){return typeof r.get===e&&typeof r.set===e}s.exports=c
});var n=i();module.exports=n;
/** @license Apache-2.0 */
//# sourceMappingURL=index.js.map
{
"version": 3,
"sources": ["../lib/main.js", "../lib/index.js"],
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar TYPE = 'function';\n\n\n// MAIN //\n\n/**\n* Tests if an array-like object supports the accessor (get/set) protocol.\n*\n* @param {Object} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn ( typeof value.get === TYPE && typeof value.set === TYPE ); // eslint-disable-line valid-typeof\n}\n\n\n// EXPORTS //\n\nmodule.exports = isAccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if an array-like object supports the accessor (get/set) protocol.\n*\n* @module @stdlib/array-base-assert-is-accessor-array\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128array' );\n* var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isAccessorArray( [] );\n* // returns false\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,WAqBX,SAASC,EAAiBC,EAAQ,CACjC,OAAS,OAAOA,EAAM,MAAQF,GAAQ,OAAOE,EAAM,MAAQF,CAC5D,CAKAD,EAAO,QAAUE,ICZjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
"names": ["require_main", "__commonJSMin", "exports", "module", "TYPE", "isAccessorArray", "value", "main"]
}
+29
-3

@@ -19,9 +19,35 @@ /*

// TypeScript Version: 2.0
// TypeScript Version: 4.1
/// <reference types="@stdlib/types"/>
import { Collection } from '@stdlib/types/object';
import { Collection } from '@stdlib/types/array';
/**
* Interface defining an array-like object supporting the accessor (get/set) protocol.
*/
interface AccessorArray {
/**
* Number of elements.
*/
length: number;
/**
* Returns an array element.
*
* @param i - element index
* @returns array element
*/
get( i: number ): any;
/**
* Sets an array element.
*
* @param value - value(s)
* @param i - element index at which to start writing values (default: 0)
*/
set( value: any, i?: number ): void;
}
/**
* Tests if an array-like object supports the accessor (get/set) protocol.

@@ -43,3 +69,3 @@ *

*/
declare function isAccessorArray( value: Collection ): boolean;
declare function isAccessorArray( value: Collection | AccessorArray ): value is AccessorArray; // tslint-disable-line max-line-length

@@ -46,0 +72,0 @@

+19
-19
{
"name": "@stdlib/array-base-assert-is-accessor-array",
"version": "0.0.1",
"version": "0.1.0",
"description": "Test if an array-like object supports the accessor (get/set) protocol.",

@@ -40,20 +40,20 @@ "license": "Apache-2.0",

"dependencies": {
"@stdlib/types": "^0.0.x"
"@stdlib/types": "^0.1.0"
},
"devDependencies": {
"@stdlib/array-complex128": "^0.0.x",
"@stdlib/array-complex64": "^0.0.x",
"@stdlib/array-float32": "^0.0.x",
"@stdlib/array-float64": "^0.0.x",
"@stdlib/array-int16": "^0.0.x",
"@stdlib/array-int32": "^0.0.x",
"@stdlib/array-int8": "^0.0.x",
"@stdlib/array-uint16": "^0.0.x",
"@stdlib/array-uint32": "^0.0.x",
"@stdlib/array-uint8": "^0.0.x",
"@stdlib/array-uint8c": "^0.0.x",
"@stdlib/assert-is-boolean": "^0.0.x",
"@stdlib/bench": "^0.0.x",
"@stdlib/buffer-alloc-unsafe": "^0.0.x",
"@stdlib/utils-constructor-name": "^0.0.x",
"@stdlib/array-complex128": "^0.0.6",
"@stdlib/array-complex64": "^0.0.6",
"@stdlib/array-float32": "^0.1.0",
"@stdlib/array-float64": "^0.1.0",
"@stdlib/array-int16": "^0.1.0",
"@stdlib/array-int32": "^0.1.0",
"@stdlib/array-int8": "^0.1.0",
"@stdlib/array-uint16": "^0.1.0",
"@stdlib/array-uint32": "^0.1.0",
"@stdlib/array-uint8": "^0.1.0",
"@stdlib/array-uint8c": "^0.1.0",
"@stdlib/assert-is-boolean": "^0.1.0",
"@stdlib/bench": "^0.1.0",
"@stdlib/buffer-alloc-unsafe": "^0.1.0",
"@stdlib/utils-constructor-name": "^0.1.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",

@@ -111,5 +111,5 @@ "istanbul": "^0.4.1",

"funding": {
"type": "patreon",
"url": "https://www.patreon.com/athan"
"type": "opencollective",
"url": "https://opencollective.com/stdlib"
}
}

@@ -21,2 +21,13 @@ <!--

<details>
<summary>
About stdlib...
</summary>
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
</details>
# isAccessorArray

@@ -196,4 +207,4 @@

[test-image]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml/badge.svg?branch=v0.0.1
[test-url]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml?query=branch:v0.0.1
[test-image]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml/badge.svg?branch=v0.1.0
[test-url]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml?query=branch:v0.1.0

@@ -211,3 +222,3 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-assert-is-accessor-array/main.svg

[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
[chat-url]: https://gitter.im/stdlib-js/stdlib/
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im

@@ -214,0 +225,0 @@ [stdlib]: https://github.com/stdlib-js/stdlib

{{alias}}( value )
Tests if an array-like object supports the accessor (get/set) protocol.
An accessor array is defined as an array, typed array, or an array-like
object (excluding strings and functions) having `get` and `set` methods for
accessing array elements.
Parameters
----------
value: ArrayLikeObject
Value to test.
Returns
-------
bool: boolean
Boolean indicating whether a value is an accessor array.
Examples
--------
> var bool = {{alias}}( new {{alias:@stdlib/array/complex64}}( 10 ) )
true
> bool = {{alias}}( [] )
false
> bool = {{alias}}( { 'length': 0 } )
false
See Also
--------
/*
* @license Apache-2.0
*
* Copyright (c) 2022 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 isAccessorArray = require( './index' );
// TESTS //
// The function returns a boolean...
{
isAccessorArray( [] ); // $ExpectType boolean
}
// The compiler throws an error if the function is provided an unsupported number of arguments...
{
isAccessorArray(); // $ExpectError
isAccessorArray( [], 123 ); // $ExpectError
}