arasatasaygin / is.js Goto Github PK
View Code? Open in Web Editor NEWMicro check library
Home Page: http://is.js.org
License: MIT License
Micro check library
Home Page: http://is.js.org
License: MIT License
Hi,
I was taking a look at the environment checks section of the library, and I've notice that you are lower-casing the User Agent. However, later you perform regexp tests ignoring the case (using the i
option), and even not ignoring the case and using uppercase letters, as in the case of Opera, which indeed doesn't work.
Perhaps an easier way to test the browser is just the one in here (which only misses the IE-version check): https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator
I would like taking this opportunity to first thank you for this nice job; but also to let here an idea: having a "builder" that allows you to select only the functions you really need (maybe at a module level), which as far as I've heard is a path that libraries like lodash will sensitively take.
Hey @arasatasaygin what do you think about adding some methods to check file extensions?
like: is.image
is.pdf
is.excel
is.extension
I'll implement is.image
tomorrow
It's fairly typical for methods that reset a library's namespace in order to avoid collision to be called noConflict
. See jQuery, Underscore, Lodash, Bootstrap, and even mainly server-side libraries like node-uuid.
I think a setNamespace
method is reserved for actually creating a new namespace on or from an object, not changing the object's current global namespace.
Hi, I've seen quite a few posts somewhere else including these checks:
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0))
Like here: http://ctrlq.org/code/19616-detect-touch-screen-javascript
and here: https://coderwall.com/p/mqd6pw/detect-touchcapability-in-javascript
Should they be added?
Can it use in node.js?
The implementation of is.sorted
return true only for array sorted in ascending order. I think for descending order, it should also returns true.
In some of my projects I need to check if a browser has at least a specific version. It would be great if I could use is.js
for that purpose.
So I would like to have a function that returns true
if a browser version is greater than or equal to a given number. Like: is.ie(8).orLater()
. Same goes for other browsers like Chrome, Firefox, etc.
hey, in my project i need this everytime. do you think it would fit in your lib? :)
isUTC: function(UTC) {
var now = new Date();
if (UTC >= new Date(now.getTime() + now.getTimezoneOffset() * 60000))
return false;
else
return true;
}
It will be great if we can validate a IP adress
This environment check is somewhat common in my codebases and I would imagine in other projects with browserify/isomorphic bits. Any opinions on is.browser()
and is.node()
?
Love this library - thanks everyone!
Hello, there.
Is there a reason you used value === void 0;
to check if value is undefined rather than typeof value === 'undefined'
?
Thanks for the awesome library, btw.
Seperating checks to the folder and file structures and compiling them may make the project easier to maintain and more modular.
checks/
type/
- array.js
- arguments.js
...
env/
- android.js
- ipad.js
...
It will make the codebase easier for someone to add new checks without breaking the core.
Could anyone tell me how to use this fantastic library in node.js?
When I using:
require ('is');
I get the error:
Can not find module 'is_js'
Still trying to figure out pull requests, until then, my attempt to fix this:
line 523:
var vendor = 'navigator' in window && 'vendor' in navigator && navigator.vendor.toLowerCase() || '';
The url is "http://v.example.com/v_show/id_XOTM1MzA5NjA4.html?from=y1.2-2.4.2-1"
It seems taking too long to match. One core of CPU is running fully.
Dose it a bug?
At last I use:
fslone@30a89e7
Some method names are not as good as it should be. (Thanks to my poor English)
However I don't want to change api so fast. So please list your suggestions on method names here for now:
Name suggestions:
@tbasse suggested here #43 :
is.under()
—> is.below()
@colindresj suggested here #23 :
is.setNamespace()
—> is.noConflict()
@njenia suggested
is.within(num, min, max)
—> is.between(num, min, max)
@Guru107 suggested
is.function()
—> is.typeFunction()
is.null()
—> is.typeNull()
Alias suggestions:
@justincampbell suggested here #78 :
is.present()
as an alias of is.existy()
Hi,
I think the OS needs some more checks to be determined accurately. In this particular case I've found that Ubuntu is not recognized as a GNU/Linux OS. The navigator.appVersion
value is "5.0 (X11)"
. Typical scripts that perform this task include a forth check to determine if the OS is Unix-like. You can see an example here: http://www.javascripter.net/faq/operatin.htm
I just listed your readme and realized that is not only a great pack of functions but a great API for a new ones. So maybe you will provide some extending function to create something like is.myExtension…
?
I want to check if a string is in integer or decimal format, is there a way to do this using is.js?
I am using jQuery first:
if (jQuery.isNumeric(input)) {
input = Number(input);
}
And then use is.js:
if (is.integer(input)) {
...
} else if (is.decimal(input)) {
...
}
Just came across a weird issue when trying to require is.js when using the module bundler webpack. In JavaScript I do:
var is = require("is_js");
When using webpack this causes webpack to freak out and give an error message like this:
ERROR in ./~/is_js/is.js
Module not found: Error: Cannot resolve module 'is' in C:\jonrh\isjs-webpack-bugExample\node_modules\is_js
@ ./~/is_js/is.js 8:8-13:10
I'm not entirely sure where the fault is but I suspect it has something to do with is.js and AMD module loading. Maybe even webpack.
I created a repository with some sample code and documentation to reproduce this issue. Included in the repository is a very hacky way to prevent this issue.
çiş@çüş.com is validated email. is it wrong?
https://www.tdn.tn/webtech/js-micro-check-library/
All they did was zip your files up and offer them for download on their site.
Hi,
Is there a npm package?
Thanks for this library!
Best regards,
Louis
This idea came from pull request #7
is.setRegexp method is now providing regexp updates for the builtin checks. We should use the same method to add new RegExps as a library users.
The library is not using 'use strict' at the moment. As a consequence it breaks when concatenated with strict mode code. It could be nice to make it compatible, they are not many triggered errors (1)
var root = this || global; // global is undefined
should become something like:
var root = (typeof global !== 'undefined' && (typeof window === 'undefined' || window === global.window)) ? global : window;
I wonder if it can be implemented in angular js eg:
angular.controller('Ctrl', ['$scope', '$isJs', function($scope, $isJs){
if($scope.someModel.is.Something()) {
doSomething;
}
}]);
i tried to check if a the given value is all white space characters.
is.space(' ') is currently returning false
i think, it should return true
or
implementation another new method called is.whitespace
is.url("foo.com bar") // true
is.url("foo.com/something.php?foo=bar") // false
is.url("foo.com/something%20else.php") // false
is.url("foo.com/page.php?foo=one+two") // false
Is this a desired behaviour?
First of all, excuse me in advance if I'm very picky here but the naming of the is.above()
and is.under()
methods are really bothering me. It really should be above/below or over/under but definitely not abover/under :)
Maybe just rename is.under()
to is.below()
and alias those methods to is.over()
and is.under()
.
Again, I might be very picky here but the current naming just looks very odd.
The regex to check if a postcode is a UK one fails with most of the postcode listed on Wikipedia page about special UK postcodes.
// is a given value number?
is.number = function(value) {
return toString.call(value) === '[object Number]';
};
should be
is.number = function(value) {
return toString.call(value) === '[object Number]' && !isNaN(value);
};
???
All four is.dayLightSavingTime()
tests are failing in Australia because the given dates in the tests do not correlate with our daylight saving times over here. Should be the same for all southern hemisphere countries.
http://en.wikipedia.org/wiki/Daylight_saving_time_by_country
For example if I have an item and I want to check to see if it's in an array I have:
is.inArray([1, 2, 3, 4, 5, 6], 2);
=> true
is.not.inArray([1, 2, 3, 4, 5, 6], 10);
=> true
Theoretically you could also do 'is.inObject()' or even 'is.inString()'.
returning false
any chance we could make this jshint friendly? is.function
will prompt usage of a reserved word.
Indicative makes use to is.js in some rules and decimal rule fails at certain point.
Here is a reference to same
poppinss/indicative#2
Also
is.decimal(10.0)
// returns false
From my side I just added a new regex like:
dateString_scored: /^(1[0-2]|0?[1-9])-(3[01]|[12][0-9]|0?[1-9])-(?:[0-9]{2})?[0-9]{2}$/,
to the regex list. Would it be possible to add validation for impossible date like 12/34/5678?
Hi,
Is there any reason to check the second expression here https://github.com/arasatasaygin/is.js/blob/master/is.js#L128?
is.null = function(value) {
return value === null || toString.call(value) === '[object Null]';
};
Could anyone clarify, why is it needed toString.call(value) === '[object Null]
?
@arasatasaygin
why is.js require itself.
if(typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['is'], function(is) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return (root.is = factory(is));
});
} else if(typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory(require('is_js'));
} else {
// Browser globals (root is window)
root.is = factory(root.is);
}
What do you think about publish this awesome package into MeteorJS's ecosystem?
as title
Hi, thanks for your great library!
I just read your documentation and found that you support checks for specific Internet Explorer versions with is.ie(value:number)
. I was wondering why don't support the same thing for Firefox, Chrome, etc. like is.chrome(value:number)
?
To be consistent and because it is helpful I suggest to add the version checks for all browsers as version checks become more and more important with the evolvement of new HTML5 features.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.