-
-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature] Improved Includes Helper #149
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
base: develop
Are you sure you want to change the base?
[Feature] Improved Includes Helper #149
Conversation
- Creates the static includesSome method in String - Checks if at least one of the given terms is included in the base string
- Creates the static includesEvery method in String - Checks if all of the given terms are included in the base string
- Adds tests for includesSome with multiple params and with an array: * shouldReturnTrueIfAtLeastOneTermMatchesUsingMultipleParams * shouldReturnTrueIfAtLeastOneTermMatchesUsingAnArray * shouldReturnFalseForIncludesSomeWithEmptyTerms - Adds tests for includesEvery with multiple params and with an array: * shouldReturnTrueOnlyIfAllTermsMatchUsingMultipleParams * shouldReturnTrueOnlyIfAllTermsMatchUsingAnArray * shouldReturnTrueForIncludesEveryWithEmptyTerms Ensures maximum coverage and verifies behavior under various conditions (e.g., no matches, partial matches, empty arrays).
|
Hey, @jlenon7, I'm a bit confused about using |
I apologize that we still don't have documentation for the About MacroableYou actually don't need String.macro('foo', function foo(this: String) {
return 'bar'
})
String.staticMacro('foo', function foo(this: String) {
return 'bar'
})
String.foo() // bar
new String().foo() // barNotice that we are using TypeScript and this class cannot infer the types of the methods and getters that the developer wants to create, so he needs to create a import { String as AthennaString } from '@athenna/common'
declare module '@athenna/common' {
class String extends AthennaString {
/**
* Output bar when called.
*/
static foo(): string;
/**
* Output bar when called.
*/
foo(): string;
}
}About your implementationKeep in mind that the Since you already implemented |
Proposed changes
Adds new static methods (
includesSomeandincludesEvery) to theStringclass, allowing checks for whether some or all of the provided search terms appear in the given string value. Includes comprehensive tests to ensure correct functionality under various scenarios.Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out aftercreating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
Further comments
These new methods solve the need for checking substring inclusions in a more flexible way (checking for at least one or for all matches). Implementation follows existing patterns in the library, and the tests added provide coverage for multiple parameters, arrays, and edge cases (e.g., empty arrays).