pp-is 1.0.7 → 1.0.9

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 +46 -80
  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.9",
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.9 (2022/09/11 23:09 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
+ function getType( value ){ return Object.prototype.toString.call(value) }
17
+ // =======================================================================
18
+ function isArray ( value ){ return getType( value ) === '[object Array]'}
15
19
  // =======================================================================
16
- var toString = Object.prototype.toString;
20
+ function isRegExp ( value ){ return getType( value ) === '[object RegExp]'}
17
21
  // =======================================================================
18
- var isArray = function( value ){
19
- return toString.call( value ) === '[object Array]'
20
- }
22
+ function isBoolean( value ){ return value === true || value === false || getType( value ) === '[object Boolean]'};
21
23
  // =======================================================================
22
- var isRegExp = function( value ){
23
- return toString.call( value ) === '[object RegExp]'
24
- }
24
+ function isDate( value ){ return getType( value ) === '[object Date]'}
25
25
  // =======================================================================
26
- var isBoolean = function( value ){
27
- return value === true || value === false || toString.call( value ) === '[object Boolean]'
28
- }
29
- // =======================================================================
30
- var isDate = function( value ){
31
- return toString.call( value ) === '[object Date]'
32
- }
26
+ function isElement( value ){ return !!( value && value.nodeType === 1 ) }
33
27
  // =======================================================================
34
- var isElement = function( value ){
35
- return !!( value && value.nodeType === 1 );
36
- }
28
+ function isFunction( value ) { return getType( value ) === '[object Function]'}
37
29
  // =======================================================================
38
- var isFunction = function( value ){
39
- return toString.call( value ) === '[object Function]'
40
- }
30
+ function isNull( value ){ return getType( value ) === '[object Null]'}
41
31
  // =======================================================================
42
- var isNull = function( value ){
43
- return toString.call( value ) === '[object Null]'
44
- }
32
+ function isNumber( value ){ return getType( value ) === '[object Number]'}
45
33
  // =======================================================================
46
- var isNumber = function( value ){
47
- return toString.call( value ) === '[object Number]'
48
- }
34
+ function isObject( value ){ return getType( value ) === '[object Object]'}
49
35
  // =======================================================================
50
- var isObject = function( value ){
51
- return toString.call( value ) === '[object Object]'
52
- }
36
+ function isString( value ){ return getType( value ) === '[object String]'}
53
37
  // =======================================================================
54
- var isString = function( value ){
55
- return toString.call( value ) === '[object String]'
56
- }
57
- // =======================================================================
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
+ function isUndefined( value ){ return getType( value ) === '[object Undefined]'}
39
+ // =======================================================================
40
+ function isEmpty( value ){
41
+ if(isStringetType(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
+ function isEmail( value ){ return /^([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
+ function isNaN( value ){ return 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
+ function isUrl( value ){ return /^(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(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(){function n(n){return Object.prototype.toString.call(n)}function t(t){return"[object Array]"===n(t)}function e(t){return"[object Function]"===n(t)}function i(t){return"[object Object]"===n(t)}var 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(t)})),isDate:r((function(t){return"[object Date]"===n(t)})),isElement:r((function(n){return!(!n||1!==n.nodeType)})),isEmpty:r((function(n){return isStringetType(n)?""===n:t(n)?0==n.length:!i(n)||0===Object.keys(n).length})),isFunction:r(e),isNull:r((function(t){return"[object Null]"===n(t)})),isNumber:r((function(t){return"[object Number]"===n(t)})),isObject:r(i),isString:r((function(t){return"[object String]"===n(t)})),isUndefined:r((function(t){return"[object Undefined]"===n(t)})),isEmail:r((function(n){return/^([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(n)})),isNaN:r((function(n){return Number.isNaN(parseInt(n))})),isRegExp:r((function(t){return"[object RegExp]"===n(t)})),isUrl:r((function(n){return/^(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(n)}))}}));