Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Create improved includes() helper #132

Open
jlenon7 opened this issue Jul 30, 2024 · 0 comments
Open

[Feature]: Create improved includes() helper #132

jlenon7 opened this issue Jul 30, 2024 · 0 comments
Labels
feature New feature or request good first issue Good for newcomers

Comments

@jlenon7
Copy link
Member

jlenon7 commented Jul 30, 2024

🚀 Feature Proposal

const value = 'hello model.id'

# Verify the existence of at least one of the values
value.athenna.includesSome('models.id', 'models.provider') // true
String.includesSome(string, 'models.id', 'models.provider') // true

# Verify the existence of all the values
value.athenna.includesEvery(['models.id', 'models.provider']) // false
String.includesEvery(string, 'models.id', 'models.provider') // false

The implementation of both helpers could be achieved by doing the following (both helpers needs to accept an array of arguments as second parameter (...args or []), where the first one will be the actual string to validate):

const value = 'hello model.id'

['models.id', 'models.provider'].some(i => value.includes(i)) // true
['models.id', 'models.provider'].every(i => value.includes(i)) // false

Motivation

Improve String helper.

Example

No response

@jlenon7 jlenon7 added the feature New feature or request label Jul 30, 2024
@jlenon7 jlenon7 assigned jlenon7 and unassigned jlenon7 Jul 30, 2024
@jlenon7 jlenon7 added the good first issue Good for newcomers label Jul 30, 2024
@jlenon7 jlenon7 added this to Athenna Jul 30, 2024
@jlenon7 jlenon7 moved this to Backlog in Athenna Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

1 participant