array-base-assert-any-has-property

Test whether at least one element in a provided array has a specified property, either own or inherited.

https://github.com/shalkyfidelis/array-base-assert-any-has-property

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.4%) to scientific vocabulary

Keywords

any array assert data generic has javascript nodejs own prop property stdlib structure types
Last synced: 6 months ago · JSON representation ·

Repository

Test whether at least one element in a provided array has a specified property, either own or inherited.

Basic Info
  • Host: GitHub
  • Owner: ShalkyFidelis
  • License: apache-2.0
  • Language: JavaScript
  • Default Branch: main
  • Size: 48.8 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 2
Topics
any array assert data generic has javascript nodejs own prop property stdlib structure types
Created 10 months ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

Array Base Assert Any Has Property

GitHub Release

Overview

Welcome to the Array Base Assert Any Has Property repository! This project provides a simple and effective way to check if at least one element in a given array possesses a specified property. This property can be either an own property or an inherited one. The utility is designed to be lightweight and easy to use in any JavaScript environment, including Node.js.

Table of Contents

Features

  • Simple Interface: Easy to use with minimal setup.
  • Flexible Checks: Works with both own and inherited properties.
  • Lightweight: Minimal impact on performance.
  • Compatibility: Works seamlessly with Node.js and browsers.

Installation

To get started, you need to install the package. You can do this using npm or yarn. Run one of the following commands in your terminal:

bash npm install array-base-assert-any-has-property

or

bash yarn add array-base-assert-any-has-property

Usage

After installing the package, you can use it in your project. Here’s a simple example of how to get started:

```javascript const hasProperty = require('array-base-assert-any-has-property');

const array = [{ name: 'Alice' }, { age: 30 }, { job: 'Engineer' }];

const result = hasProperty(array, 'age'); console.log(result); // true ```

API Reference

hasProperty(array, property)

  • Parameters:

    • array: An array of objects to be checked.
    • property: A string representing the property name to check for.
  • Returns:

    • true if at least one object in the array has the specified property.
    • false otherwise.

Example

javascript const array = [{ name: 'Alice' }, { age: 30 }, { job: 'Engineer' }]; console.log(hasProperty(array, 'name')); // true console.log(hasProperty(array, 'salary')); // false

Examples

Here are a few more examples to illustrate how the utility works:

Example 1: Checking Own Properties

javascript const array = [{ name: 'Alice' }, { age: 30 }, { job: 'Engineer' }]; console.log(hasProperty(array, 'job')); // true

Example 2: Checking Inherited Properties

```javascript function Person(name, age) { this.name = name; this.age = age; }

const array = [new Person('Alice', 30), new Person('Bob', 25)]; console.log(hasProperty(array, 'age')); // true ```

Example 3: No Matching Property

javascript const array = [{ name: 'Alice' }, { job: 'Engineer' }]; console.log(hasProperty(array, 'salary')); // false

Contributing

We welcome contributions! If you want to help improve this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes.
  4. Submit a pull request.

Please ensure your code adheres to the project's coding standards and includes tests for any new features.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For issues, questions, or suggestions, please check the Releases section for updates and information.

Feel free to reach out via the GitHub Issues page if you need further assistance.

Conclusion

The Array Base Assert Any Has Property utility provides a straightforward way to validate properties in arrays. Its simple interface and flexible design make it a valuable tool for any JavaScript developer.

To explore the latest releases, visit the Releases section.

Happy coding!

Owner

  • Login: ShalkyFidelis
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

Dependencies

package.json npm
  • @stdlib/array-base-to-accessor-array ^0.2.2 development
  • @stdlib/array-filled ^0.2.1 development
  • @stdlib/array-filled-by ^0.2.1 development
  • @stdlib/assert-is-boolean ^0.2.2 development
  • @stdlib/bench-harness ^0.2.2 development
  • @stdlib/math-base-special-pow ^0.3.0 development
  • @stdlib/random-base-discrete-uniform ^0.2.1 development
  • @stdlib/string-from-code-point ^0.2.2 development
  • istanbul ^0.4.1 development
  • tap-min git+https://github.com/Planeshifter/tap-min.git development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/array-base-assert-is-accessor-array ^0.2.2
  • @stdlib/array-base-resolve-getter ^0.2.2
  • @stdlib/assert-has-property ^0.2.2
  • @stdlib/types ^0.4.3