pp-is 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +2 -3
  2. package/pp-is.js +45 -79
  3. package/pp-is.min.js +1 -1
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
- "devDependencies": {},
3
2
  "name": "pp-is",
4
3
  "description": "Collection of methods for check",
5
- "version": "1.0.7",
4
+ "version": "1.0.8",
6
5
  "main": "pp-is.js",
7
6
  "scripts": {
8
- "compile":"terser --output pp-is.min.js --compress --mangle --comments false -- pp-is.js "
7
+ "compile": "terser --output pp-is.min.js --compress --mangle --comments false -- pp-is.js"
9
8
  },
10
9
  "repository": {
11
10
  "type": "git",
package/pp-is.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!!
2
2
  * Power Panel pp-is <https://github.com/carlos-sweb/pp-is>
3
3
  * @author Carlos Illesca
4
- * @version 1.0.7 (2020/09/04 00:34 PM)
4
+ * @version 1.0.8 (2022/09/11 22:26 PM)
5
5
  * Released under the MIT License
6
6
  */
7
7
  (function(global,factory){
@@ -12,85 +12,51 @@
12
12
  }()
13
13
  ));
14
14
  })(this,function(){
15
+ // =======================================================================
16
+ getType = ( value) => Object.prototype.toString.call(value);
15
17
  // =======================================================================
16
- var toString = Object.prototype.toString;
18
+ isArray = ( value ) => getType( value ) === '[object Array]';
17
19
  // =======================================================================
18
- var isArray = function( value ){
19
- return toString.call( value ) === '[object Array]'
20
- }
20
+ isRegExp = ( value ) => getType( value ) === '[object RegExp]';
21
21
  // =======================================================================
22
- var isRegExp = function( value ){
23
- return toString.call( value ) === '[object RegExp]'
24
- }
22
+ isBoolean = ( value ) => value === true || value === false || getType( value ) === '[object Boolean]';
25
23
  // =======================================================================
26
- var isBoolean = function( value ){
27
- return value === true || value === false || toString.call( value ) === '[object Boolean]'
28
- }
24
+ isDate = ( value ) => getType( value ) === '[object Date]';
29
25
  // =======================================================================
30
- var isDate = function( value ){
31
- return toString.call( value ) === '[object Date]'
32
- }
26
+ isElement = ( value ) => !!( value && value.nodeType === 1 );
33
27
  // =======================================================================
34
- var isElement = function( value ){
35
- return !!( value && value.nodeType === 1 );
36
- }
28
+ isFunction = ( value ) => getType( value ) === '[object Function]';
37
29
  // =======================================================================
38
- var isFunction = function( value ){
39
- return toString.call( value ) === '[object Function]'
40
- }
41
- // =======================================================================
42
- var isNull = function( value ){
43
- return toString.call( value ) === '[object Null]'
44
- }
30
+ isNull = ( value ) => getType( value ) === '[object Null]';
45
31
  // =======================================================================
46
- var isNumber = function( value ){
47
- return toString.call( value ) === '[object Number]'
48
- }
32
+ isNumber = ( value ) => getType( value ) === '[object Number]';
49
33
  // =======================================================================
50
- var isObject = function( value ){
51
- return toString.call( value ) === '[object Object]'
52
- }
34
+ isObject = ( value ) => getType( value ) === '[object Object]';
53
35
  // =======================================================================
54
- var isString = function( value ){
55
- return toString.call( value ) === '[object String]'
56
- }
36
+ isString = ( value ) => getType( value ) === '[object String]';
57
37
  // =======================================================================
58
- var isUndefined = function( value ){
59
- return toString.call( value ) === '[object Undefined]'
60
- }
61
- var isEmpty = function( value ){
62
- if( isString(value) ){
63
- return value.trim() === "";
64
- }
65
- if( isArray(value) ){
66
- return value.length == 0;
67
- }
68
- if( isObject(value) ){
69
- return Object.keys(value).length === 0;
70
- }
71
-
38
+ isUndefined = ( value ) => getType( value ) === '[object Undefined]';
39
+ // =======================================================================
40
+ isEmpty = ( value ) => {
41
+ if(isString(value)){ return value === ""; }
42
+ if(isArray(value) ){ return value.length == 0; }
43
+ if(isObject(value) ){ return Object.keys(value).length === 0;}
72
44
  return true;
73
45
  }
74
46
  // =======================================================================
75
- var isEmail = function( value ){
76
- // get from https://fightingforalostcause.net/content/misc/2006/compare-email-regex.php
77
- var patternEmail = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;
78
- return patternEmail.test( value )
79
- }
47
+ // Investigar Sobre los dominios de cada pais y de cada segmento comercial o publico personal
48
+ isEmail = ( value ) => /^([a-z0-9_-]+[a-z0-9._-]+?)@([a-z0-9-]+\.[a-z]{2,6}|[a-z0-9]+\.[a-z]{2,6}\.[a-z]{2,6})$/i.test( value );
80
49
  // =======================================================================
81
- var isNaN = function( value ){
82
- return Number.isNaN( parseInt(value) )
83
- }
50
+ isNaN = ( value ) => Number.isNaN( parseInt(value) );
84
51
  // =======================================================================
85
- var isUrl = function( value ){
86
- var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
87
- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
88
- '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
89
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
90
- '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
91
- '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
92
- return !!pattern.test(value);
93
- }
52
+ // ^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)? protocol
53
+ // ([w]{3}\.|[w]{3}2\.)? ([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,} Domain name www or www2
54
+ // localhost -> include this word
55
+ // [\d]+\.[\d]+\.[\d]+\.[\d]+ -> add ipv4
56
+ // (\:[\d]+)? -> port
57
+ // ([\??\/?]+[\/;&a-z\d%_.~+=-]*)? -> query url
58
+ // (\#[\/;&a-z\d%_.~+=-]*)? -> hashtag url
59
+ isUrl = ( value ) => /^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)?([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,}|localhost|[\d]+\.[\d]+\.[\d]+\.[\d]+)(\:[\d]+)?([\??\/?]+[\/;&a-z\d%_.~+=-]*)?(\#[\/;&a-z\d%_.~+=-]*)?$/gi.test(value);
94
60
  // =======================================================================
95
61
  var base = function( func ){
96
62
  // Retornamos una funcion
@@ -106,20 +72,20 @@
106
72
  }
107
73
  // =======================================================================
108
74
  return {
109
- isArray:base(isArray),
110
- isBoolean:base(isBoolean),
111
- isDate:base(isDate),
112
- isElement:base(isElement),
113
- isEmpty:base(isEmpty),
114
- isFunction:base(isFunction),
115
- isNull:base(isNull),
116
- isNumber:base(isNumber),
117
- isObject:base(isObject),
118
- isString:base(isString),
119
- isUndefined:base(isUndefined),
120
- isEmail:base(isEmail),
121
- isNaN:base(isNaN),
122
- isRegExp:base(isRegExp),
123
- isUrl:base(isUrl)
75
+ 'isArray':base(isArray),
76
+ 'isBoolean':base(isBoolean),
77
+ 'isDate':base(isDate),
78
+ 'isElement':base(isElement),
79
+ 'isEmpty':base(isEmpty),
80
+ 'isFunction':base(isFunction),
81
+ 'isNull':base(isNull),
82
+ 'isNumber':base(isNumber),
83
+ 'isObject':base(isObject),
84
+ 'isString':base(isString),
85
+ 'isUndefined':base(isUndefined),
86
+ 'isEmail':base(isEmail),
87
+ 'isNaN':base(isNaN),
88
+ 'isRegExp':base(isRegExp),
89
+ 'isUrl':base(isUrl)
124
90
  }
125
91
  })
package/pp-is.min.js CHANGED
@@ -1 +1 @@
1
- !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ppIs",t):(n=n||self).ppIs=t()}(this,(function(){var n=Object.prototype.toString,t=function(t){return"[object Array]"===n.call(t)},e=function(t){return"[object Function]"===n.call(t)},i=function(t){return"[object Object]"===n.call(t)},o=function(t){return"[object String]"===n.call(t)},r=function(n){return function(t,i){return e(i)?n(t)?i(t):void 0:n(t)}};return{isArray:r(t),isBoolean:r((function(t){return!0===t||!1===t||"[object Boolean]"===n.call(t)})),isDate:r((function(t){return"[object Date]"===n.call(t)})),isElement:r((function(n){return!(!n||1!==n.nodeType)})),isEmpty:r((function(n){return o(n)?""===n.trim():t(n)?0==n.length:!i(n)||0===Object.keys(n).length})),isFunction:r(e),isNull:r((function(t){return"[object Null]"===n.call(t)})),isNumber:r((function(t){return"[object Number]"===n.call(t)})),isObject:r(i),isString:r(o),isUndefined:r((function(t){return"[object Undefined]"===n.call(t)})),isEmail:r((function(n){return/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i.test(n)})),isNaN:r((function(n){return Number.isNaN(parseInt(n))})),isRegExp:r((function(t){return"[object RegExp]"===n.call(t)})),isUrl:r((function(n){return!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(n)}))}}));
1
+ !function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define("ppIs",i):(e=e||self).ppIs=i()}(this,(function(){getType=e=>Object.prototype.toString.call(e),isArray=e=>"[object Array]"===getType(e),isRegExp=e=>"[object RegExp]"===getType(e),isBoolean=e=>!0===e||!1===e||"[object Boolean]"===getType(e),isDate=e=>"[object Date]"===getType(e),isElement=e=>!(!e||1!==e.nodeType),isFunction=e=>"[object Function]"===getType(e),isNull=e=>"[object Null]"===getType(e),isNumber=e=>"[object Number]"===getType(e),isObject=e=>"[object Object]"===getType(e),isString=e=>"[object String]"===getType(e),isUndefined=e=>"[object Undefined]"===getType(e),isEmpty=e=>isString(e)?""===e:isArray(e)?0==e.length:!isObject(e)||0===Object.keys(e).length,isEmail=e=>/^([a-z0-9_-]+[a-z0-9._-]+?)@([a-z0-9-]+\.[a-z]{2,6}|[a-z0-9]+\.[a-z]{2,6}\.[a-z]{2,6})$/i.test(e),isNaN=e=>Number.isNaN(parseInt(e)),isUrl=e=>/^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)?([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,}|localhost|[\d]+\.[\d]+\.[\d]+\.[\d]+)(\:[\d]+)?([\??\/?]+[\/;&a-z\d%_.~+=-]*)?(\#[\/;&a-z\d%_.~+=-]*)?$/gi.test(e);var e=function(e){return function(i,t){return isFunction(t)?e(i)?t(i):void 0:e(i)}};return{isArray:e(isArray),isBoolean:e(isBoolean),isDate:e(isDate),isElement:e(isElement),isEmpty:e(isEmpty),isFunction:e(isFunction),isNull:e(isNull),isNumber:e(isNumber),isObject:e(isObject),isString:e(isString),isUndefined:e(isUndefined),isEmail:e(isEmail),isNaN:e(isNaN),isRegExp:e(isRegExp),isUrl:e(isUrl)}}));