这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@jlaguio
Copy link
Contributor

@jlaguio jlaguio commented Feb 23, 2025

Justification

A common pattern in my codebase is to check for inequalities. But sometimes 13 must be included in the range. The typical solution is to do...

if (is(x).thirteen() && is(x).greater.than.thirteen()) {
  //... something
}

This can be a bit tedious to write and cumbersome for code readability.

Solution

This PR add methods that aggregates the condition into a single convenient function

if (is(x).greater.than.or.equal.thirteen()) {
  //... something
}

The example above allows for a cleaner code, enhancing the readability experience.
This should also benefit other codebases.

Additional Changes

13 new test cases has also been added to ensure that the changes don't break when new functionality is added or existing ones are modified.
I've also noticed that the not operation doesn't have an existing test so I've added one for it for good measure.

is-thirteen$ npm run test

image

edit: Added sample of tests successfully running

Copy link
Collaborator

@Almenon Almenon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice lol

@Almenon Almenon merged commit 0f64bac into jezen:master Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants