pp-is 1.1.0 → 1.2.1

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.
package/README.md CHANGED
@@ -94,6 +94,18 @@ Checks if value is a valid Url.
94
94
 
95
95
  ---
96
96
 
97
+ #### `isNodeList`
98
+
99
+ Checks if value is a valid NodeList.
100
+
101
+ ---
102
+
103
+ #### `isHTMLCollection`
104
+
105
+ Checks if value is a valid HTMLCollection.
106
+
107
+ ---
108
+
97
109
  ## How to use ?
98
110
 
99
111
  ```javascript
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pp-is",
3
3
  "description": "Collection of methods for check",
4
- "version": "1.1.0",
4
+ "version": "1.2.1",
5
5
  "main": "pp-is.js",
6
6
  "scripts": {
7
7
  "compile": "terser --output pp-is.min.js --compress --mangle --comments false -- pp-is.js"
@@ -25,7 +25,9 @@
25
25
  "isEmail",
26
26
  "isNaN",
27
27
  "isRegExp",
28
- "isUrl"
28
+ "isUrl",
29
+ "isHTMLCollection",
30
+ "isNodeList"
29
31
  ],
30
32
  "author": "Carlos Illesca",
31
33
  "license": "MIT",
package/pp-is.js CHANGED
@@ -1,91 +1,105 @@
1
1
  /*!!
2
2
  * Power Panel pp-is <https://github.com/carlos-sweb/pp-is>
3
3
  * @author Carlos Illesca
4
- * @version 1.1.0 (2022/10/02 20:41 PM)
4
+ * @version 1.2.1 (2024/02/26 15:00 PM)
5
5
  * Released under the MIT License
6
6
  */
7
- (function(global,factory){
8
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9
- typeof define === 'function' && define.amd ? define('ppIs', factory) :
10
- (global = global || self, (function () {
11
- var exports = global.ppIs = factory();
12
- }()
13
- ));
14
- })(this,function(){
15
- // =======================================================================
16
- function getType( value ){ return Object.prototype.toString.call(value) }
17
- // =======================================================================
18
- function isArray ( value ){ return getType( value ) === '[object Array]'}
19
- // =======================================================================
20
- function isRegExp ( value ){ return getType( value ) === '[object RegExp]'}
21
- // =======================================================================
22
- function isBoolean( value ){ return value === true || value === false || getType( value ) === '[object Boolean]'};
23
- // =======================================================================
24
- function isDate( value ){ return getType( value ) === '[object Date]'}
25
- // =======================================================================
26
- function isElement( value ){ return !!( value && value.nodeType === 1 ) }
27
- // =======================================================================
28
- function isFunction( value ) { return getType( value ) === '[object Function]'}
29
- // =======================================================================
30
- function isNull( value ){ return getType( value ) === '[object Null]'}
31
- // =======================================================================
32
- function isNumber( value ){ return getType( value ) === '[object Number]'}
33
- // =======================================================================
34
- function isObject( value ){ return getType( value ) === '[object Object]'}
35
- // =======================================================================
36
- function isString( value ){ return getType( value ) === '[object String]'}
37
- // =======================================================================
38
- function isUndefined( value ){ return getType( value ) === '[object Undefined]'}
39
- // =======================================================================
40
- function 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;}
44
- return true;
45
- }
46
- // =======================================================================
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 )}
49
- // =======================================================================
50
- function isNaN( value ){ return Number.isNaN( parseInt(value) )}
51
- // =======================================================================
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)}
60
- // =======================================================================
61
- var base = function( func ){
62
- // Retornamos una funcion
63
- return function( value , done ){
64
- if( isFunction( done ) ){
65
- if( func( value ) ){
66
- return done( value )
67
- }
68
- }else{
69
- return func(value)
70
- }
7
+ ;(function(){
8
+
9
+ function is(){
10
+ const getType = ( value )=>Object.prototype.toString.call(value),
11
+ getTypeCompare = (value,expresion) =>(getType(value) === expresion),
12
+ isNodeList = ( value )=>(typeof NodeList === "undefined" ? false : NodeList.prototype.isPrototypeOf(value)),
13
+ isHTMLCollection = ( value )=>(typeof HTMLCollection === "undefined" ? false : HTMLCollection.prototype.isPrototypeOf(value)),
14
+ isArray = ( value )=>getTypeCompare(value,'[object Array]'),
15
+ isRegExp = ( value )=>getTypeCompare(value,'[object RegExp]'),
16
+ isBoolean = ( value )=>value === true || value === false || getType( value ) === '[object Boolean]',
17
+ isDate = ( value )=>getTypeCompare(value,'[object Date]'),
18
+ isElement = ( value )=>!!( value && value.nodeType === 1 ) ,
19
+ isFunction = ( value ) =>getTypeCompare(value,'[object Function]'),
20
+ isNull = ( value )=>getTypeCompare(value,'[object Null]'),
21
+ isNumber = ( value )=>getTypeCompare(value,'[object Number]'),
22
+ isObject = (value )=>getTypeCompare(value,'[object Object]'),
23
+ isString = ( value )=>getTypeCompare(value,'[object String]'),
24
+ isUndefined = ( value )=>getTypeCompare(value,'[object Undefined]'),
25
+
26
+ isEmpty=( value )=>{
27
+ if(isString(value)){ return value === "" }
28
+ else if(isArray(value) ){ return value.length == 0 }
29
+ else if(isObject(value) ){ return Object.keys(value).length === 0}
30
+ return true;
31
+ },
32
+ // =======================================================================
33
+ // Investigar Sobre los dominios de cada pais y de cada segmento comercial o publico personal
34
+ 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 )},
35
+ // =======================================================================
36
+ isNaN = ( value )=>(Number.isNaN( parseInt(value))),
37
+ // =======================================================================
38
+ // ^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)? protocol
39
+ // ([w]{3}\.|[w]{3}2\.)? ([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,} Domain name www or www2
40
+ // localhost -> include this word
41
+ // [\d]+\.[\d]+\.[\d]+\.[\d]+ -> add ipv4
42
+ // (\:[\d]+)? -> port
43
+ // ([\??\/?]+[\/;&a-z\d%_.~+=-]*)? -> query url
44
+ // (\#[\/;&a-z\d%_.~+=-]*)? -> hashtag url
45
+ 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)},
46
+ // =======================================================================
47
+ base = ( func )=>{
48
+ return ( value , done )=>{
49
+ if( isFunction( done ) ){
50
+ if( func( value ) ){
51
+ return done( value )
52
+ }
53
+ }else{
54
+ return func(value)
71
55
  }
72
- }
73
- // =======================================================================
74
- return {
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)
90
- }
91
- })
56
+ }
57
+ }
58
+ // =======================================================================
59
+ return {
60
+ isArray:base(isArray),
61
+ isBoolean:base(isBoolean),
62
+ isDate:base(isDate),
63
+ isElement:base(isElement),
64
+ isEmpty:base(isEmpty),
65
+ isFunction:base(isFunction),
66
+ isNull:base(isNull),
67
+ isNumber:base(isNumber),
68
+ isObject:base(isObject),
69
+ isString:base(isString),
70
+ isUndefined:base(isUndefined),
71
+ isEmail:base(isEmail),
72
+ isNaN:base(isNaN),
73
+ isRegExp:base(isRegExp),
74
+ isUrl:base(isUrl),
75
+ isNodeList:base(isNodeList),
76
+ isHTMLCollection:base(isHTMLCollection)
77
+ }
78
+ }
79
+
80
+ /** Detect free variable `global` from Node.js. */
81
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
82
+
83
+ /** Detect free variable `self`. */
84
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
85
+
86
+ /** Used as a reference to the global object. */
87
+ var root = freeGlobal || freeSelf || Function('return this')();
88
+
89
+ /** Detect free variable `exports`. */
90
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
91
+
92
+ /** Detect free variable `module`. */
93
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
94
+
95
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd){
96
+ define(function(){
97
+ return is();
98
+ });
99
+ }
100
+ else if( freeModule ){
101
+ freeModule.exports = is()
102
+ }else{
103
+ root.ppIs = is();
104
+ }
105
+ }.call(this))
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(){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 r(t){return"[object Object]"===n(t)}function i(t){return"[object String]"===n(t)}var o=function(n){return function(t,r){return e(r)?n(t)?r(t):void 0:n(t)}};return{isArray:o(t),isBoolean:o((function(t){return!0===t||!1===t||"[object Boolean]"===n(t)})),isDate:o((function(t){return"[object Date]"===n(t)})),isElement:o((function(n){return!(!n||1!==n.nodeType)})),isEmpty:o((function(n){return i(n)?""===n:t(n)?0==n.length:!r(n)||0===Object.keys(n).length})),isFunction:o(e),isNull:o((function(t){return"[object Null]"===n(t)})),isNumber:o((function(t){return"[object Number]"===n(t)})),isObject:o(r),isString:o(i),isUndefined:o((function(t){return"[object Undefined]"===n(t)})),isEmail:o((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:o((function(n){return Number.isNaN(parseInt(n))})),isRegExp:o((function(t){return"[object RegExp]"===n(t)})),isUrl:o((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)}))}}));
1
+ (function(){function e(){const e=e=>Object.prototype.toString.call(e),t=(t,o)=>e(t)===o,o=e=>t(e,"[object Array]"),i=e=>t(e,"[object Function]"),n=e=>t(e,"[object Object]"),s=e=>t(e,"[object String]"),l=e=>(t,o)=>i(o)?e(t)?o(t):void 0:e(t);return{isArray:l(o),isBoolean:l((t=>!0===t||!1===t||"[object Boolean]"===e(t))),isDate:l((e=>t(e,"[object Date]"))),isElement:l((e=>!(!e||1!==e.nodeType))),isEmpty:l((e=>s(e)?""===e:o(e)?0==e.length:!n(e)||0===Object.keys(e).length)),isFunction:l(i),isNull:l((e=>t(e,"[object Null]"))),isNumber:l((e=>t(e,"[object Number]"))),isObject:l(n),isString:l(s),isUndefined:l((e=>t(e,"[object Undefined]"))),isEmail:l((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:l((e=>Number.isNaN(parseInt(e)))),isRegExp:l((e=>t(e,"[object RegExp]"))),isUrl:l((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))),isNodeList:l((e=>"undefined"!=typeof NodeList&&NodeList.prototype.isPrototypeOf(e))),isHTMLCollection:l((e=>"undefined"!=typeof HTMLCollection&&HTMLCollection.prototype.isPrototypeOf(e)))}}var t="object"==typeof global&&global&&global.Object===Object&&global,o="object"==typeof self&&self&&self.Object===Object&&self,i=t||o||Function("return this")(),n="object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define((function(){return e()})):n?n.exports=e():i.ppIs=e()}).call(this);