-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Ideas #1
Comments
How are you thinking is.withinRange = (x, arr) => (x > Math.min.apply(Math, arr)) && (x < Math.max.apply(Math, arr)); |
@glhrmv I was thinking: is.withinRange = (input, [lower, upper]) => input >= lower && input <= upper; |
Array destructuring is definitely more elegant, I forgot that was a thing. As for |
Yup. Let’s do it in a separate test file. |
I couldn't make I'm giving this up to anyone who wants to deal with it, and I'm interested to see how this type of issue is solved. |
@glhrmv You can see how it's done here: https://github.com/sindresorhus/linkify-urls/blob/4db31ab79d62dc0adf6b3c086a6a68f955343918/test.js#L2-L7 |
With #4:
|
Hey @sindresorhus, Hacktoberfest is upon us! 😜 How about getting some more eyes on this issue/repo with the relevant tag? |
what about include it in AVA t.is ? |
@fega wouldn't that create some weird circular dependency? |
@gioragutt nope, you would just install the latest version at the ava project Unrelated, what about: const a = 5;
const b = {};
const c = 'asd';
is.string(a,b,c); // false |
@noamokman what is the case you're checking here exactly? this returns false because the method only relates to what do you expect this to return? |
|
I mean that if multiple values are passed is should test all values |
@noamokman perheps we can implement that into is.all = (pred, ...values) => {
if (!is.array(values) || is.empty(values)) {
return false;
}
const hits = values.find(pred);
return hits.length === values.length;
}; and |
No, that's should be a separate method. |
👍 See how to do it here: https://github.com/sindresorhus/is-observable/blob/master/index.js
Already included.
What is this and why do you need to detect it? Can you link to some reading material? |
@sindresorhus Subjects are extended from Observables. They are basically Observables you can call |
Could I get more insight into what is expected from .any and .all ? is.any(value, [types] ) ? Is it similar for .all? |
@melvin0008 I guess this is up for discussion, because as you stated, there are many ways to interpret @sindresorhus your thoughts? |
|
Regarding, Returns any(predicate, values…) Returns all(predicate, values…) Example: any(is.string, {}, true, '🦄');
//=> true |
👍 And |
Others for consideration:
Update: Added a few more... total brain dump. Glad to implement any of these pending need / usefulness. |
Datesis.inRange(new Date('March 1, 2017'), [new Date('January 1, 2017'), new Date('July 1, 2017')])
// => true
date.getTime() >= min && date.getTime() <= max Questions:
Text - Alphabeticalis.inRange('Brandon', ['Andrew', 'Cole'])
// => true
name >= min && name <= max Questions:
|
Use-case?
I don't like the looseness of this. We should not mix types like that. We could have
👍
I considered this when doing
👍
We already have
👍 , but:
👍
I would make a new method for this:
👎 I don't see the point in supporting a range for this. |
I'd prefer
I honestly think that doing this would reduce code readability. If we wish to keep the API cleaner, this might not be a good idea to do those methods. But if you believe this wouldn't create much of a bloat, then I'm fine with it.
Do you mean that And there are definitely use cases for checking against a lower bound.
I agree with you on that there's no point in a range (this is basically But this does give 2 new ideas:
and this in turn makes sense to include |
Agreed, but should be
I'm -0. Maybe if someone can convince me it has benefits of including it over just using the operators.
No,
Use-case?
Use-case? |
👎 No one should be using the
I guess this is the same case as
👍 Since we already alias some other useful native methods.
This is already included as
Not clear enough name. And, use-case?
Use-case? |
@brandon93s Awesome braindump! :) |
Appreciate the feedback!
|
I've had to work on a project where emojis in the username were disallowed altogether. That's another use-case. |
That's a good use-case. I'm 👍 on this now. |
We won't add anything for legacy reasons.
This is a good use-case though. I'm 👍 on this. |
Most of this should be implemented now. Let's open new issues for additional requests. |
I'm gonna try hard not to go overboard with stuff I will never need, but just a quick brain dump:
.withinRange(3, [0, 5])
.generator()
.domElement()
.generatorFunction()
.infinity()
(Would matchInfinity
and-Infinity
) (Maybe.infinite()
would be a better name?).empty([])
(string, array, object, map, set, ...).blob()
.asyncFunction()
.any()
/.all()
methods to match multiple types.Feedback wanted! 😀
The text was updated successfully, but these errors were encountered: