๐ก Introduction
Idea
thiis
package was created in order to simplify writing in typescript / javascript, it often happens that you need to have
checks for different types of data, these checks can be "huge", but if you could simply describe in words what we want
to check?
For example, why write:
if (typeof variable === 'object' && variable !== null && !Array.isArray(variable) && Object.keys(variable)?.length) {
}
if you can write something like:
if (is.object_not_empty(variable)) {
}
Why you should use and support the package:โ
- โ
60+ prepared methods, prefixed with
_not_
more than 120 and with_or_
more than 14,000 and with a global state of more than 2,000,000 combined methods. - โ Typification.
- โ Reducing the code in the project.
- โ Easier to read and understand the code.
- โ CDN support.
- โ Compatible with ECMAScript 2015.
- โ Compatible with the oldest version of TypeScript (0.8.0).
- โ Maintenance of global contexts: globalThis, window, self, global.
- โ No dependencies
- โ AMD, Node & browser ready
- โ Small size: ~8KB.
- โ Collection of RegExp patterns (33 items).
- โ
Magic methods:
is.len_
,len_gt_N_lt_N
,len_lt_N
,len_gt_N
,len_gte_N_lt_N
,len_gte_N_lte_N
,len_lte_N
,len_gte_N
,len_gt_N_lte_N
Size | Methods | Prefix .not. | Unifier .or. | Combinations | Combinations with global | Compatibility |
---|---|---|---|---|---|---|
~8KB | 60+ | โ | โ | 14,000+ | 2,000,000+ | Web + Node |
Explanationโ
Combinationโ
It means that you can combine between the declared commands more than 14k times, for example: is.string_not_empty()
, is.string_or_number()
and so on. You can use non-combined commands, for example: is.string()
, which will increase the performance of your code, or combine between commands, but then this effect will affect the productivity of the code, which indicates that you should not use combined commands in the most important parts of the code, for example, on the server , but for user-side applications will not lead to noticeable effects.
Combinations with globalโ
Also, by default, the package has access to globally declared commands, this possibility can be blocked via IsConfig
. This option allows you to write your own checking commands, for example, if you want to check whether $variable is a Map, you just need to write is.Map($variable) and you will get a result depending on whether $variable is of type Map or not (true, false). To explain, the Map method is not declared, it is generic, that is, by entering the name of the type, the package will look for this type in the global scope, and if it finds it, it will take it and use it for this: $variable instanceof Map
.
Such possibilities in the package are limited only by the available types in the global scope, some of them are already declared in the interface (here is the link: Global Command) and for HTML types (here is the link HTML types). That is, in this way, if you know that there is some type declared globally, but it is not declared in the package, then there is nothing wrong, feel free to use it, the package will find it :)
๐ค Contributingโ
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request ๐
โ๏ธ Authorsโ
- Ivan Karbashevskyi - Initial work - Karbashevskyi
See also the list of contributors who participated in this project.
๐ Licenseโ
MIT License ยฉ Karbashevskyi