pp-is 1.2.1 → 1.2.2
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/LICENSE.txt +21 -0
- package/README.md +21 -5
- package/README_es.md +146 -0
- package/dist/pp-is.js +321 -0
- package/dist/pp-is.min.js +1 -0
- package/package.json +6 -3
- package/test/config/webpack.config.js +13 -0
- package/test/dist/pp-is.app.bundle.js +2 -0
- package/test/dist/pp-is.app.bundle.js.LICENSE.txt +6 -0
- package/test/index.webpack.html +13 -0
- package/test/js/main.requirejs.js +12 -0
- package/test/js/main.webpack.js +1 -0
- package/test/js/pp-is.js +321 -0
- package/pp-is.js +0 -105
- package/pp-is.min.js +0 -1
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Carlos Enrique Illesca Monsalve
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
In the web project include pp-is.js with:
|
|
6
6
|
|
|
7
7
|
```html
|
|
8
|
-
<script src="https://cdn.jsdelivr.net/npm/pp-is@
|
|
8
|
+
<script src="https://cdn.jsdelivr.net/npm/pp-is@1.2.2/pp-is.min.js" ></script>
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Or
|
|
@@ -119,12 +119,28 @@ if( ppIs.isString(value) ){
|
|
|
119
119
|
|
|
120
120
|
### or
|
|
121
121
|
|
|
122
|
+
|
|
123
|
+
|
|
122
124
|
```javascript
|
|
125
|
+
// You can make an extra evaluation
|
|
126
|
+
const done = ( value ) => {
|
|
127
|
+
return value !== 'string';
|
|
128
|
+
}
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
const reject = ( value ) => {
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const value = 'string';
|
|
125
135
|
|
|
126
|
-
ppIs.isString( value ,
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
const result = ppIs.isString( value , done , reject );
|
|
137
|
+
|
|
138
|
+
if( result ){
|
|
139
|
+
|
|
140
|
+
}else{
|
|
141
|
+
|
|
142
|
+
}
|
|
129
143
|
|
|
130
144
|
```
|
|
145
|
+
|
|
146
|
+
[Lea este documento en español](./README_es.md)
|
package/README_es.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# pp-is
|
|
2
|
+
|
|
3
|
+
## Para empezar
|
|
4
|
+
|
|
5
|
+
Incluye pp-is.js en tu proyecto web:
|
|
6
|
+
```html
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/pp-is@1.2.2/pp-is.min.js" ></script>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
O
|
|
11
|
+
|
|
12
|
+
## Instalación
|
|
13
|
+
|
|
14
|
+
```console
|
|
15
|
+
npm i pp-is --save
|
|
16
|
+
```
|
|
17
|
+
## Metodos
|
|
18
|
+
|
|
19
|
+
#### `isArray`
|
|
20
|
+
|
|
21
|
+
Verifica si el valor es clasificado como un Objecto de Array.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
#### `isBoolean`
|
|
25
|
+
|
|
26
|
+
Verifica si el valor is verdadero ( true ) o falso ( false ).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
#### `isDate`
|
|
30
|
+
|
|
31
|
+
Verifica si el valor es una Fecha.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
#### `isElement`
|
|
35
|
+
|
|
36
|
+
verifica si el valor es un elemento del DOM
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
#### `isFunction`
|
|
41
|
+
|
|
42
|
+
Verifica si el valor es una función
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
#### `isNull`
|
|
46
|
+
|
|
47
|
+
Verifica si el valor es un nulo.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
#### `isNumber`
|
|
51
|
+
|
|
52
|
+
Verifica si el valor es un numero.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
#### `isObject`
|
|
56
|
+
|
|
57
|
+
verifica si el valor es clasificado como un objecto.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
#### `isString`
|
|
61
|
+
|
|
62
|
+
Varifica si el valor es una cadena de texto.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
#### `isUndefined`
|
|
66
|
+
|
|
67
|
+
verifica si el valor esta no definido.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
#### `isEmail`
|
|
71
|
+
|
|
72
|
+
Verifica si el valor es un correo electronico valido.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
#### `isNaN`
|
|
78
|
+
|
|
79
|
+
Verifica si el valor es un numero valido proveniente de una cadena de texto.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
#### `isRegExp`
|
|
85
|
+
|
|
86
|
+
Verifica si el valor es una expresion regular
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
#### `isUrl`
|
|
92
|
+
|
|
93
|
+
Verifica si el valor es una url valida.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
#### `isNodeList`
|
|
98
|
+
|
|
99
|
+
Verifica si el valor es un NodeList valido.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
#### `isHTMLCollection`
|
|
104
|
+
|
|
105
|
+
Verifica si el valor es un HTTMLCollection valido.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## ¿ Como se usa ?
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
|
|
113
|
+
var value = "string...";
|
|
114
|
+
|
|
115
|
+
if( ppIs.isString(value) ){
|
|
116
|
+
// Ingresa tu codigo aqui
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### or
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
// Puedes hacer una evaluación extra
|
|
126
|
+
const done = ( value ) => {
|
|
127
|
+
return value !== 'string';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const reject = ( value ) => {
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const value = 'string';
|
|
135
|
+
|
|
136
|
+
const result = ppIs.isString( value , done , reject );
|
|
137
|
+
|
|
138
|
+
if( result ){
|
|
139
|
+
|
|
140
|
+
}else{
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
[Read this document in English](./README.md)
|
package/dist/pp-is.js
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/*!!
|
|
2
|
+
* Power Panel pp-is <https://github.com/carlos-sweb/pp-is>
|
|
3
|
+
* @author Carlos Illesca
|
|
4
|
+
* @version 1.2.3 (2024/09/18 15:14 PM)
|
|
5
|
+
* Released under the MIT License
|
|
6
|
+
*/
|
|
7
|
+
;(function(){
|
|
8
|
+
"use strict";
|
|
9
|
+
/**
|
|
10
|
+
* @function getType
|
|
11
|
+
* @description - Gets the type name
|
|
12
|
+
* @param {Any} value - Value to check
|
|
13
|
+
* @returns {string}
|
|
14
|
+
* @example
|
|
15
|
+
* const s = 'Hello Word';
|
|
16
|
+
* console.log(getType(s))
|
|
17
|
+
* // [object String]
|
|
18
|
+
*/
|
|
19
|
+
const getType=(value)=>Object.prototype.toString.call(value),
|
|
20
|
+
/**
|
|
21
|
+
* @description - This function checks for the presence of `define` in the global scope and checks if it is configured as an AMD module.
|
|
22
|
+
* @function getAMD
|
|
23
|
+
* @return {object} - define object if exists
|
|
24
|
+
*/
|
|
25
|
+
getAMD = ()=>typeof define == 'function' && typeof define.amd == 'object' && define.amd,
|
|
26
|
+
/**
|
|
27
|
+
* @function isAMD
|
|
28
|
+
* @description - check if AMD is a Object
|
|
29
|
+
* @return {boolean} - AMD works
|
|
30
|
+
*/
|
|
31
|
+
isAMD=()=>isObject(getAMD()),
|
|
32
|
+
/**
|
|
33
|
+
* @function getFreeGlobal
|
|
34
|
+
* @descriptcion - Detect free variable `global`
|
|
35
|
+
* @return {object}
|
|
36
|
+
*/
|
|
37
|
+
getFreeGlobal=()=>(typeof global == 'object' && global && global.Object === Object && global),
|
|
38
|
+
/**
|
|
39
|
+
* @function getFreeGlobal
|
|
40
|
+
* @descriptcion - Detect free variable `self`
|
|
41
|
+
* @return {object}
|
|
42
|
+
*/
|
|
43
|
+
getFreeSelf=()=>(typeof self == 'object' && self && self.Object === Object && self),
|
|
44
|
+
/**
|
|
45
|
+
* @name getRoot
|
|
46
|
+
* @description - Used as a reference to the global object.
|
|
47
|
+
* @function
|
|
48
|
+
* @return {object}
|
|
49
|
+
*/
|
|
50
|
+
getRoot=()=>{
|
|
51
|
+
return getFreeGlobal() || getFreeSelf() || Function('return this')();
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* @function isFreeExports
|
|
55
|
+
* @description - Detect free variable `exports`
|
|
56
|
+
* @return {boolean} -
|
|
57
|
+
*/
|
|
58
|
+
isFreeExports =()=>(typeof exports == 'object' && exports && !exports.nodeType && exports),
|
|
59
|
+
/**
|
|
60
|
+
* @function getFreeModule
|
|
61
|
+
* @description - Detect free variable `module`.
|
|
62
|
+
* @return {object} - variable `module`
|
|
63
|
+
*/
|
|
64
|
+
getFreeModule=()=>(isFreeExports() && typeof module == 'object' && module && !module.nodeType && module),
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @function isFreeModule
|
|
68
|
+
* @description - detect if variable module is Object
|
|
69
|
+
* @param { Any } value - Any value
|
|
70
|
+
* @return {boolean}
|
|
71
|
+
*/
|
|
72
|
+
isFreeModule=()=>isObject(getFreeModule()),
|
|
73
|
+
/**
|
|
74
|
+
* @function getTypeCompare
|
|
75
|
+
* @description -
|
|
76
|
+
* @param {Any} value - Any Value
|
|
77
|
+
* @param {string} expression - Expression to compare
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
getTypeCompare=(value,expression)=>(getType(value) === "[object "+expression+"]"),
|
|
81
|
+
/**
|
|
82
|
+
* @function isNodeList
|
|
83
|
+
* @description - Checks if value is a valid NodeList.
|
|
84
|
+
* @param { Any } value - Any Value
|
|
85
|
+
* @return {boolean}
|
|
86
|
+
*/
|
|
87
|
+
isNodeList=(value)=>(typeof NodeList === "undefined" ? false : NodeList.prototype.isPrototypeOf(value)),
|
|
88
|
+
/**
|
|
89
|
+
* @function isHTMLCollection
|
|
90
|
+
* @description - Checks if value is a valid HTMLCollection.
|
|
91
|
+
* @param { Any } value - Any Value
|
|
92
|
+
* @return {boolean}
|
|
93
|
+
*/
|
|
94
|
+
isHTMLCollection=(value)=>(typeof HTMLCollection === "undefined" ? false : HTMLCollection.prototype.isPrototypeOf(value)),
|
|
95
|
+
/**
|
|
96
|
+
* @function isArray
|
|
97
|
+
* @description - Checks if value is classified as an Array object.
|
|
98
|
+
* @param { Any } value - Any Value
|
|
99
|
+
* @return {boolean}
|
|
100
|
+
*/
|
|
101
|
+
isArray=(value)=>getTypeCompare(value,'Array'),
|
|
102
|
+
/**
|
|
103
|
+
* @function isRegExp
|
|
104
|
+
* @description - Checks if value is a RegExp.
|
|
105
|
+
* @param { Any } value - Any value
|
|
106
|
+
* @return {boolean}
|
|
107
|
+
*/
|
|
108
|
+
isRegExp=(value)=>getTypeCompare(value,'RegExp'),
|
|
109
|
+
/**
|
|
110
|
+
* @function isBoolean
|
|
111
|
+
* @description - Checks if value is either true or false.
|
|
112
|
+
* @param { Any } value - Any value
|
|
113
|
+
* @return {boolean}
|
|
114
|
+
*/
|
|
115
|
+
isBoolean=(value)=>value === true || value === false || getTypeCompare(value,'Boolean'),
|
|
116
|
+
/**
|
|
117
|
+
* @function isDate
|
|
118
|
+
* @description - isDate
|
|
119
|
+
* @param { Any } value - Any value
|
|
120
|
+
* @return {boolean}
|
|
121
|
+
*/
|
|
122
|
+
isDate=(value)=>getTypeCompare(value,'Date'),
|
|
123
|
+
/**
|
|
124
|
+
* @function isElement
|
|
125
|
+
* @description - isElement
|
|
126
|
+
* @param { Any } value - Any value
|
|
127
|
+
* @return {boolean}
|
|
128
|
+
*/
|
|
129
|
+
isElement=(value)=>!!( value && value.nodeType === 1 ) ,
|
|
130
|
+
/**
|
|
131
|
+
* @function isFunction
|
|
132
|
+
* @description - Checks if value is a Function.
|
|
133
|
+
* @param { Any } value - Any value
|
|
134
|
+
* @return {boolean}
|
|
135
|
+
*/
|
|
136
|
+
isFunction=(value) =>getTypeCompare(value,'Function'),
|
|
137
|
+
/**
|
|
138
|
+
* @function isNull
|
|
139
|
+
* @description - Checks if value is a Null.
|
|
140
|
+
* @param { Any } value - Any value
|
|
141
|
+
* @return {boolean}
|
|
142
|
+
*/
|
|
143
|
+
isNull=(value)=>getTypeCompare(value,'Null'),
|
|
144
|
+
/**
|
|
145
|
+
* @function isNumber
|
|
146
|
+
* @description - Checks if value is a Number.
|
|
147
|
+
* @param { Any } value - Any value
|
|
148
|
+
* @return {boolean}
|
|
149
|
+
*/
|
|
150
|
+
isNumber=(value)=>getTypeCompare(value,'Number'),
|
|
151
|
+
/**
|
|
152
|
+
* @function isObject
|
|
153
|
+
* @description - Checks if value is classified as an Object.
|
|
154
|
+
* @param { Any } value - Any value
|
|
155
|
+
* @return {boolean}
|
|
156
|
+
*/
|
|
157
|
+
isObject=(value)=>getTypeCompare(value,'Object'),
|
|
158
|
+
/**
|
|
159
|
+
* @function isString
|
|
160
|
+
* @description - Checks if value is a string.
|
|
161
|
+
* @param { Any } value - Any value
|
|
162
|
+
* @return {boolean}
|
|
163
|
+
*/
|
|
164
|
+
isString=(value)=>getTypeCompare(value,'String'),
|
|
165
|
+
/**
|
|
166
|
+
* @function isUndefined
|
|
167
|
+
* @description - Checks if value is a undefined.
|
|
168
|
+
* @param { Any } value - Any value
|
|
169
|
+
* @return {boolean}
|
|
170
|
+
*/
|
|
171
|
+
isUndefined=(value)=>getTypeCompare(value,'Undefined'),
|
|
172
|
+
/**
|
|
173
|
+
* @function isEmpty
|
|
174
|
+
* @description - Checks if value is not empty
|
|
175
|
+
* @param { Any } value - Any value
|
|
176
|
+
* @example
|
|
177
|
+
* // this a empty string
|
|
178
|
+
* is.isEmpty("")
|
|
179
|
+
* // return true
|
|
180
|
+
* @example
|
|
181
|
+
* // this a empty array
|
|
182
|
+
* is.isEmpty([])
|
|
183
|
+
* // return true
|
|
184
|
+
* @example
|
|
185
|
+
* // this a empty Object
|
|
186
|
+
* is.isEmpty({})
|
|
187
|
+
* // return true
|
|
188
|
+
* @return {boolean}
|
|
189
|
+
*/
|
|
190
|
+
isEmpty=(value)=>{
|
|
191
|
+
if(isString(value)){return value === ""}
|
|
192
|
+
else if(isArray(value)){return value.length == 0}
|
|
193
|
+
else if(isObject(value)){return Object.keys(value).length === 0}
|
|
194
|
+
return true;
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* @function isEmail
|
|
198
|
+
* @description - Checks if value is a valid email.
|
|
199
|
+
* @param { Any } value - Any Value
|
|
200
|
+
* @example
|
|
201
|
+
* is.isEmail("h@blog.mydomian.xyz")
|
|
202
|
+
* // return true
|
|
203
|
+
* @return {boolean}
|
|
204
|
+
*/
|
|
205
|
+
isEmail = ( value )=>/^([a-z1-9\._-]+)@([a-z0-9-]+\.[a-z]{2,11}|[a-z0-9]+\.[a-z]{2,24}\.[a-z]{2,24})$/i.test( value ),
|
|
206
|
+
/**
|
|
207
|
+
* @function isNaN
|
|
208
|
+
* @description - Checks if value is a valid Number from String.
|
|
209
|
+
* @param { Any } value - Any Value
|
|
210
|
+
* @return {boolean}
|
|
211
|
+
*/
|
|
212
|
+
isNaN = ( value )=>(Number.isNaN( parseInt(value))),
|
|
213
|
+
// =======================================================================
|
|
214
|
+
// ^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)? protocol
|
|
215
|
+
// ([w]{3}\.|[w]{3}2\.)? ([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,} Domain name www or www2
|
|
216
|
+
// localhost -> include this word
|
|
217
|
+
// [\d]+\.[\d]+\.[\d]+\.[\d]+ -> add ipv4
|
|
218
|
+
// (\:[\d]+)? -> port
|
|
219
|
+
// ([\??\/?]+[\/;&a-z\d%_.~+=-]*)? -> query url
|
|
220
|
+
// (\#[\/;&a-z\d%_.~+=-]*)? -> hashtag url
|
|
221
|
+
/**
|
|
222
|
+
* @function isUrl
|
|
223
|
+
* @description - Checks if value is a valid Url.
|
|
224
|
+
* @param { Any } value - Any Value
|
|
225
|
+
* @return {boolean}
|
|
226
|
+
*/
|
|
227
|
+
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),
|
|
228
|
+
|
|
229
|
+
// =======================================================================
|
|
230
|
+
/**
|
|
231
|
+
* @function baseSanetize
|
|
232
|
+
* @description - Trabajar Aqui
|
|
233
|
+
* @param { function } doneOrReject - Custom function that is triggered when the positive hook or negative hook is defined by the user. This function can resolve true or false independent of the first evaluation or it can simply do nothing.
|
|
234
|
+
* @param { Any } value - The value to evaluate
|
|
235
|
+
* @param { boolean } evaluate - pre evaulate from static function isString,isUndefined,..etc
|
|
236
|
+
* @return { boolean } - evaluate
|
|
237
|
+
*/
|
|
238
|
+
baseSanetize = ( doneOrReject , value , evaluate )=> {
|
|
239
|
+
const response = doneOrReject(value);
|
|
240
|
+
return isBoolean( response ) ? response : evaluate;
|
|
241
|
+
},
|
|
242
|
+
/**
|
|
243
|
+
* @function baseEvaluate
|
|
244
|
+
* @description - Responsible for evaluation
|
|
245
|
+
* @param {function} func - Evaluative function
|
|
246
|
+
* @param {Any} value - The value to evaluate
|
|
247
|
+
* @param {function} done - Function to be executed in case the evaluation is positive.
|
|
248
|
+
* @param {function} reject - Function to be executed in case the evaluation is negative.
|
|
249
|
+
* @return {boolean} - value of the evaluation
|
|
250
|
+
*/
|
|
251
|
+
baseEvaluate = (func , value , done , reject) => {
|
|
252
|
+
const evaluate = func(value);
|
|
253
|
+
return evaluate ? isFunction( done ) ? baseSanetize(done,value,evaluate) : true : isFunction( reject ) ? baseSanetize(reject,value,evaluate) : false ;
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* @function base
|
|
257
|
+
* @description - This function stretches to baseEvaluate passing as parameter the function that specifically evaluates the given value to be evaluated, but in the baseEvaluate function it arrives as a parameter called func
|
|
258
|
+
* @param {function} func - Evaluative function
|
|
259
|
+
* @return {function} - function to execute baseEvaluate
|
|
260
|
+
* @example
|
|
261
|
+
* const hello = "hello Word!";
|
|
262
|
+
* const evaluate = base(isString)(hello)
|
|
263
|
+
* //return true
|
|
264
|
+
*/
|
|
265
|
+
base = ( func ) => ( value ,done , reject) => baseEvaluate( func , value , done , reject),
|
|
266
|
+
/**
|
|
267
|
+
* @description - Obtains the object to be exported with the following main functions
|
|
268
|
+
* @name is
|
|
269
|
+
* @type {object}
|
|
270
|
+
* @property {function} isArray - {@link isArray}
|
|
271
|
+
* @property {function} isBoolean - {@link isBoolean}
|
|
272
|
+
* @property {function} isDate - {@link isDate}
|
|
273
|
+
* @property {function} isElement - {@link isElement}
|
|
274
|
+
* @property {function} isEmpty - {@link isEmpty}
|
|
275
|
+
* @property {function} isFunction - {@link isFunction}
|
|
276
|
+
* @property {function} isNull - {@link isNull}
|
|
277
|
+
* @property {function} isNumber - {@link isNumber}
|
|
278
|
+
* @property {function} isString - {@link isString}
|
|
279
|
+
* @property {function} isUndefined - {@link isUndefined}
|
|
280
|
+
* @property {function} isEmail - {@link isEmail}
|
|
281
|
+
* @property {function} isNaN - {@link isNaN}
|
|
282
|
+
* @property {function} isRegExp - {@link isRegExp}
|
|
283
|
+
* @property {function} isUrl - {@link isUrl}
|
|
284
|
+
* @property {function} isNodeList - {@link isNodeList}
|
|
285
|
+
* @property {function} isHTMLCollection - {@link isHTMLCollection}
|
|
286
|
+
* @property {function} isAMD - {@link isAMD}
|
|
287
|
+
* @property {function} isFreeModule - {@link isFreeModule}
|
|
288
|
+
* @property {function} getRoot - {@link getRoot}
|
|
289
|
+
*/
|
|
290
|
+
is = {
|
|
291
|
+
'isArray':base(isArray),
|
|
292
|
+
'isBoolean':base(isBoolean),
|
|
293
|
+
'isDate':base(isDate),
|
|
294
|
+
'isElement':base(isElement),
|
|
295
|
+
'isEmpty':base(isEmpty),
|
|
296
|
+
'isFunction':base(isFunction),
|
|
297
|
+
'isNull':base(isNull),
|
|
298
|
+
'isNumber':base(isNumber),
|
|
299
|
+
'isObject':base(isObject),
|
|
300
|
+
'isString':base(isString),
|
|
301
|
+
'isUndefined':base(isUndefined),
|
|
302
|
+
'isEmail':base(isEmail),
|
|
303
|
+
'isNaN':base(isNaN),
|
|
304
|
+
'isRegExp':base(isRegExp),
|
|
305
|
+
'isUrl':base(isUrl),
|
|
306
|
+
'isNodeList':base(isNodeList),
|
|
307
|
+
'isHTMLCollection':base(isHTMLCollection),
|
|
308
|
+
'isAMD':base(isAMD),
|
|
309
|
+
'isFreeModule':base(isFreeModule),
|
|
310
|
+
'getRoot':getRoot
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
//
|
|
315
|
+
is.isAMD(null,()=>{define(()=>is)},()=>{
|
|
316
|
+
is.isFreeModule(null,()=>{ module.exports = is; },()=>{
|
|
317
|
+
is.getRoot().ppIs = is
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
}.call(this))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const e=()=>"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module,t=(e,t)=>(e=>Object.prototype.toString.call(e))(e)==="[object "+t+"]",o=e=>t(e,"Array"),i=e=>!0===e||!1===e||t(e,"Boolean"),s=e=>t(e,"Function"),l=e=>t(e,"Object"),n=e=>t(e,"String"),d=(e,t,o)=>{const s=e(t);return i(s)?s:o},p=e=>(t,o,i)=>((e,t,o,i)=>{const l=e(t);return l?!s(o)||d(o,t,l):!!s(i)&&d(i,t,l)})(e,t,o,i),r={isArray:p(o),isBoolean:p(i),isDate:p((e=>t(e,"Date"))),isElement:p((e=>!(!e||1!==e.nodeType))),isEmpty:p((e=>n(e)?""===e:o(e)?0==e.length:!l(e)||0===Object.keys(e).length)),isFunction:p(s),isNull:p((e=>t(e,"Null"))),isNumber:p((e=>t(e,"Number"))),isObject:p(l),isString:p(n),isUndefined:p((e=>t(e,"Undefined"))),isEmail:p((e=>/^([a-z1-9\._-]+)@([a-z0-9-]+\.[a-z]{2,11}|[a-z0-9]+\.[a-z]{2,24}\.[a-z]{2,24})$/i.test(e))),isNaN:p((e=>Number.isNaN(parseInt(e)))),isRegExp:p((e=>t(e,"RegExp"))),isUrl:p((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:p((e=>"undefined"!=typeof NodeList&&NodeList.prototype.isPrototypeOf(e))),isHTMLCollection:p((e=>"undefined"!=typeof HTMLCollection&&HTMLCollection.prototype.isPrototypeOf(e))),isAMD:p((()=>l("function"==typeof define&&"object"==typeof define.amd&&define.amd))),isFreeModule:p((()=>l(e()))),getRoot:()=>"object"==typeof global&&global&&global.Object===Object&&global||"object"==typeof self&&self&&self.Object===Object&&self||Function("return this")()};r.isAMD(null,(()=>{define((()=>r))}),(()=>{r.isFreeModule(null,(()=>{module.exports=r}),(()=>{r.getRoot().ppIs=r}))}))}).call(this);
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pp-is",
|
|
3
3
|
"description": "Collection of methods for check",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"main": "pp-is.js",
|
|
6
|
-
"scripts":
|
|
7
|
-
"
|
|
6
|
+
"scripts" :{
|
|
7
|
+
"djs":"documentation build ./dist/pp-is.js -f html -o ./djs && php -S localhost:8091 -t ./djs",
|
|
8
|
+
"docs" : "jsdoc ./dist/pp-is.js -d docs && php -S localhost:8091 -t ./docs",
|
|
9
|
+
"serve-webpack" : "cp dist/pp-is.js ./test/js/ && webpack --config ./test/config/webpack.config.js && php -S localhost:8090 -t ./test",
|
|
10
|
+
"compile" : "terser --output dist/pp-is.min.js --compress --mangle --comments false -- dist/pp-is.js"
|
|
8
11
|
},
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see pp-is.app.bundle.js.LICENSE.txt */
|
|
2
|
+
(()=>{var e={343:function(e,t,o){var i;e=o.nmd(e),function(){"use strict";const n=(e,t)=>(e=>Object.prototype.toString.call(e))(e)==="[object "+t+"]",s=e=>n(e,"Array"),r=e=>!0===e||!1===e||n(e,"Boolean"),l=e=>n(e,"Function"),a=e=>n(e,"Object"),c=e=>n(e,"String"),d=(e,t,o)=>{const i=e(t);return r(i)?i:o},u=e=>(t,o,i)=>((e,t,o,i)=>{const n=e(t);return n?!l(o)||d(o,t,n):!!l(i)&&d(i,t,n)})(e,t,o,i),p={isArray:u(s),isBoolean:u(r),isDate:u((e=>n(e,"Date"))),isElement:u((e=>!(!e||1!==e.nodeType))),isEmpty:u((e=>c(e)?""===e:s(e)?0==e.length:!a(e)||0===Object.keys(e).length)),isFunction:u(l),isNull:u((e=>n(e,"Null"))),isNumber:u((e=>n(e,"Number"))),isObject:u(a),isString:u(c),isUndefined:u((e=>n(e,"Undefined"))),isEmail:u((e=>/^([a-z1-9\._-]+)@([a-z0-9-]+\.[a-z]{2,11}|[a-z0-9]+\.[a-z]{2,24}\.[a-z]{2,24})$/i.test(e))),isNaN:u((e=>Number.isNaN(parseInt(e)))),isRegExp:u((e=>n(e,"RegExp"))),isUrl:u((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:u((e=>"undefined"!=typeof NodeList&&NodeList.prototype.isPrototypeOf(e))),isHTMLCollection:u((e=>"undefined"!=typeof HTMLCollection&&HTMLCollection.prototype.isPrototypeOf(e))),isAMD:u((()=>a(o.amdO))),isFreeModule:u((()=>a(t&&!t.nodeType&&t&&e&&!e.nodeType&&e))),getRoot:()=>"object"==typeof o.g&&o.g&&o.g.Object===Object&&o.g||"object"==typeof self&&self&&self.Object===Object&&self||Function("return this")()};p.isAMD(null,(()=>{void 0===(i=(()=>p).call(t,o,t,e))||(e.exports=i)}),(()=>{p.isFreeModule(null,(()=>{e.exports=p}),(()=>{p.getRoot().ppIs=p}))}))}.call(this)}},t={};function o(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}o.amdO={},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e=o(343),t=o.n(e);console.log("Testing....."),console.log("Check 100:",t().isNumber(100)),t().isNumber(100,(()=>{console.log("Esto es numero Felicitaciones")}))})()})();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>pp-is.js - webpack</title>
|
|
7
|
+
<!--<script data-main="main" src="https://requirejs.org/docs/release/2.3.7/minified/require.js"></script>-->
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<script type="text/javascript" src="dist/pp-is.app.bundle.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import is from './pp-is.js'
|
package/test/js/pp-is.js
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/*!!
|
|
2
|
+
* Power Panel pp-is <https://github.com/carlos-sweb/pp-is>
|
|
3
|
+
* @author Carlos Illesca
|
|
4
|
+
* @version 1.2.3 (2024/10/06 23:25 PM)
|
|
5
|
+
* Released under the MIT License
|
|
6
|
+
*/
|
|
7
|
+
;(function(){
|
|
8
|
+
"use strict";
|
|
9
|
+
/**
|
|
10
|
+
* @function getType
|
|
11
|
+
* @description - Gets the type name
|
|
12
|
+
* @param {Any} value - Value to check
|
|
13
|
+
* @returns {string}
|
|
14
|
+
* @example
|
|
15
|
+
* const s = 'Hello Word';
|
|
16
|
+
* console.log(getType(s))
|
|
17
|
+
* // [object String]
|
|
18
|
+
*/
|
|
19
|
+
const getType=(value)=>Object.prototype.toString.call(value),
|
|
20
|
+
/**
|
|
21
|
+
* @description - This function checks for the presence of `define` in the global scope and checks if it is configured as an AMD module.
|
|
22
|
+
* @function getAMD
|
|
23
|
+
* @return {object} - define object if exists
|
|
24
|
+
*/
|
|
25
|
+
getAMD = ()=>typeof define == 'function' && typeof define.amd == 'object' && define.amd,
|
|
26
|
+
/**
|
|
27
|
+
* @function isAMD
|
|
28
|
+
* @description - check if AMD is a Object
|
|
29
|
+
* @return {boolean} - AMD works
|
|
30
|
+
*/
|
|
31
|
+
isAMD=()=>isObject(getAMD()),
|
|
32
|
+
/**
|
|
33
|
+
* @function getFreeGlobal
|
|
34
|
+
* @descriptcion - Detect free variable `global`
|
|
35
|
+
* @return {object}
|
|
36
|
+
*/
|
|
37
|
+
getFreeGlobal=()=>(typeof global == 'object' && global && global.Object === Object && global),
|
|
38
|
+
/**
|
|
39
|
+
* @function getFreeGlobal
|
|
40
|
+
* @descriptcion - Detect free variable `self`
|
|
41
|
+
* @return {object}
|
|
42
|
+
*/
|
|
43
|
+
getFreeSelf=()=>(typeof self == 'object' && self && self.Object === Object && self),
|
|
44
|
+
/**
|
|
45
|
+
* @name getRoot
|
|
46
|
+
* @description - Used as a reference to the global object.
|
|
47
|
+
* @function
|
|
48
|
+
* @return {object}
|
|
49
|
+
*/
|
|
50
|
+
getRoot=()=>{
|
|
51
|
+
return getFreeGlobal() || getFreeSelf() || Function('return this')();
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* @function isFreeExports
|
|
55
|
+
* @description - Detect free variable `exports`
|
|
56
|
+
* @return {boolean} -
|
|
57
|
+
*/
|
|
58
|
+
isFreeExports =()=>(typeof exports == 'object' && exports && !exports.nodeType && exports),
|
|
59
|
+
/**
|
|
60
|
+
* @function getFreeModule
|
|
61
|
+
* @description - Detect free variable `module`.
|
|
62
|
+
* @return {object} - variable `module`
|
|
63
|
+
*/
|
|
64
|
+
getFreeModule=()=>(isFreeExports() && typeof module == 'object' && module && !module.nodeType && module),
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @function isFreeModule
|
|
68
|
+
* @description - detect if variable module is Object
|
|
69
|
+
* @param { Any } value - Any value
|
|
70
|
+
* @return {boolean}
|
|
71
|
+
*/
|
|
72
|
+
isFreeModule=()=>isObject(getFreeModule()),
|
|
73
|
+
/**
|
|
74
|
+
* @function getTypeCompare
|
|
75
|
+
* @description -
|
|
76
|
+
* @param {Any} value - Any Value
|
|
77
|
+
* @param {string} expression - Expression to compare
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
getTypeCompare=(value,expression)=>(getType(value) === "[object "+expression+"]"),
|
|
81
|
+
/**
|
|
82
|
+
* @function isNodeList
|
|
83
|
+
* @description - Checks if value is a valid NodeList.
|
|
84
|
+
* @param { Any } value - Any Value
|
|
85
|
+
* @return {boolean}
|
|
86
|
+
*/
|
|
87
|
+
isNodeList=(value)=>(typeof NodeList === "undefined" ? false : NodeList.prototype.isPrototypeOf(value)),
|
|
88
|
+
/**
|
|
89
|
+
* @function isHTMLCollection
|
|
90
|
+
* @description - Checks if value is a valid HTMLCollection.
|
|
91
|
+
* @param { Any } value - Any Value
|
|
92
|
+
* @return {boolean}
|
|
93
|
+
*/
|
|
94
|
+
isHTMLCollection=(value)=>(typeof HTMLCollection === "undefined" ? false : HTMLCollection.prototype.isPrototypeOf(value)),
|
|
95
|
+
/**
|
|
96
|
+
* @function isArray
|
|
97
|
+
* @description - Checks if value is classified as an Array object.
|
|
98
|
+
* @param { Any } value - Any Value
|
|
99
|
+
* @return {boolean}
|
|
100
|
+
*/
|
|
101
|
+
isArray=(value)=>getTypeCompare(value,'Array'),
|
|
102
|
+
/**
|
|
103
|
+
* @function isRegExp
|
|
104
|
+
* @description - Checks if value is a RegExp.
|
|
105
|
+
* @param { Any } value - Any value
|
|
106
|
+
* @return {boolean}
|
|
107
|
+
*/
|
|
108
|
+
isRegExp=(value)=>getTypeCompare(value,'RegExp'),
|
|
109
|
+
/**
|
|
110
|
+
* @function isBoolean
|
|
111
|
+
* @description - Checks if value is either true or false.
|
|
112
|
+
* @param { Any } value - Any value
|
|
113
|
+
* @return {boolean}
|
|
114
|
+
*/
|
|
115
|
+
isBoolean=(value)=>value === true || value === false || getTypeCompare(value,'Boolean'),
|
|
116
|
+
/**
|
|
117
|
+
* @function isDate
|
|
118
|
+
* @description - isDate
|
|
119
|
+
* @param { Any } value - Any value
|
|
120
|
+
* @return {boolean}
|
|
121
|
+
*/
|
|
122
|
+
isDate=(value)=>getTypeCompare(value,'Date'),
|
|
123
|
+
/**
|
|
124
|
+
* @function isElement
|
|
125
|
+
* @description - isElement
|
|
126
|
+
* @param { Any } value - Any value
|
|
127
|
+
* @return {boolean}
|
|
128
|
+
*/
|
|
129
|
+
isElement=(value)=>!!( value && value.nodeType === 1 ) ,
|
|
130
|
+
/**
|
|
131
|
+
* @function isFunction
|
|
132
|
+
* @description - Checks if value is a Function.
|
|
133
|
+
* @param { Any } value - Any value
|
|
134
|
+
* @return {boolean}
|
|
135
|
+
*/
|
|
136
|
+
isFunction=(value) =>getTypeCompare(value,'Function'),
|
|
137
|
+
/**
|
|
138
|
+
* @function isNull
|
|
139
|
+
* @description - Checks if value is a Null.
|
|
140
|
+
* @param { Any } value - Any value
|
|
141
|
+
* @return {boolean}
|
|
142
|
+
*/
|
|
143
|
+
isNull=(value)=>getTypeCompare(value,'Null'),
|
|
144
|
+
/**
|
|
145
|
+
* @function isNumber
|
|
146
|
+
* @description - Checks if value is a Number.
|
|
147
|
+
* @param { Any } value - Any value
|
|
148
|
+
* @return {boolean}
|
|
149
|
+
*/
|
|
150
|
+
isNumber=(value)=>getTypeCompare(value,'Number'),
|
|
151
|
+
/**
|
|
152
|
+
* @function isObject
|
|
153
|
+
* @description - Checks if value is classified as an Object.
|
|
154
|
+
* @param { Any } value - Any value
|
|
155
|
+
* @return {boolean}
|
|
156
|
+
*/
|
|
157
|
+
isObject=(value)=>getTypeCompare(value,'Object'),
|
|
158
|
+
/**
|
|
159
|
+
* @function isString
|
|
160
|
+
* @description - Checks if value is a string.
|
|
161
|
+
* @param { Any } value - Any value
|
|
162
|
+
* @return {boolean}
|
|
163
|
+
*/
|
|
164
|
+
isString=(value)=>getTypeCompare(value,'String'),
|
|
165
|
+
/**
|
|
166
|
+
* @function isUndefined
|
|
167
|
+
* @description - Checks if value is a undefined.
|
|
168
|
+
* @param { Any } value - Any value
|
|
169
|
+
* @return {boolean}
|
|
170
|
+
*/
|
|
171
|
+
isUndefined=(value)=>getTypeCompare(value,'Undefined'),
|
|
172
|
+
/**
|
|
173
|
+
* @function isEmpty
|
|
174
|
+
* @description - Checks if value is not empty
|
|
175
|
+
* @param { Any } value - Any value
|
|
176
|
+
* @example
|
|
177
|
+
* // this a empty string
|
|
178
|
+
* is.isEmpty("")
|
|
179
|
+
* // return true
|
|
180
|
+
* @example
|
|
181
|
+
* // this a empty array
|
|
182
|
+
* is.isEmpty([])
|
|
183
|
+
* // return true
|
|
184
|
+
* @example
|
|
185
|
+
* // this a empty Object
|
|
186
|
+
* is.isEmpty({})
|
|
187
|
+
* // return true
|
|
188
|
+
* @return {boolean}
|
|
189
|
+
*/
|
|
190
|
+
isEmpty=(value)=>{
|
|
191
|
+
if(isString(value)){return value === ""}
|
|
192
|
+
else if(isArray(value)){return value.length == 0}
|
|
193
|
+
else if(isObject(value)){return Object.keys(value).length === 0}
|
|
194
|
+
return true;
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* @function isEmail
|
|
198
|
+
* @description - Checks if value is a valid email.
|
|
199
|
+
* @param { Any } value - Any Value
|
|
200
|
+
* @example
|
|
201
|
+
* is.isEmail("h@blog.mydomian.xyz")
|
|
202
|
+
* // return true
|
|
203
|
+
* @return {boolean}
|
|
204
|
+
*/
|
|
205
|
+
isEmail = ( value )=>/^([a-z1-9\._-]+)@([a-z0-9-]+\.[a-z]{2,11}|[a-z0-9]+\.[a-z]{2,24}\.[a-z]{2,24})$/i.test( value ),
|
|
206
|
+
/**
|
|
207
|
+
* @function isNaN
|
|
208
|
+
* @description - Checks if value is a valid Number from String.
|
|
209
|
+
* @param { Any } value - Any Value
|
|
210
|
+
* @return {boolean}
|
|
211
|
+
*/
|
|
212
|
+
isNaN = ( value )=>(Number.isNaN( parseInt(value))),
|
|
213
|
+
// =======================================================================
|
|
214
|
+
// ^(https?:\/\/)?([w]{3}\.|[w]{3}2\.)? protocol
|
|
215
|
+
// ([w]{3}\.|[w]{3}2\.)? ([a-z\d]+\.)?([a-z\d]+\.[a-z]{2,} Domain name www or www2
|
|
216
|
+
// localhost -> include this word
|
|
217
|
+
// [\d]+\.[\d]+\.[\d]+\.[\d]+ -> add ipv4
|
|
218
|
+
// (\:[\d]+)? -> port
|
|
219
|
+
// ([\??\/?]+[\/;&a-z\d%_.~+=-]*)? -> query url
|
|
220
|
+
// (\#[\/;&a-z\d%_.~+=-]*)? -> hashtag url
|
|
221
|
+
/**
|
|
222
|
+
* @function isUrl
|
|
223
|
+
* @description - Checks if value is a valid Url.
|
|
224
|
+
* @param { Any } value - Any Value
|
|
225
|
+
* @return {boolean}
|
|
226
|
+
*/
|
|
227
|
+
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),
|
|
228
|
+
|
|
229
|
+
// =======================================================================
|
|
230
|
+
/**
|
|
231
|
+
* @function baseSanetize
|
|
232
|
+
* @description - Trabajar Aqui
|
|
233
|
+
* @param { function } doneOrReject - Custom function that is triggered when the positive hook or negative hook is defined by the user. This function can resolve true or false independent of the first evaluation or it can simply do nothing.
|
|
234
|
+
* @param { Any } value - The value to evaluate
|
|
235
|
+
* @param { boolean } evaluate - pre evaulate from static function isString,isUndefined,..etc
|
|
236
|
+
* @return { boolean } - evaluate
|
|
237
|
+
*/
|
|
238
|
+
baseSanetize = ( doneOrReject , value , evaluate )=> {
|
|
239
|
+
const response = doneOrReject(value);
|
|
240
|
+
return isBoolean( response ) ? response : evaluate;
|
|
241
|
+
},
|
|
242
|
+
/**
|
|
243
|
+
* @function baseEvaluate
|
|
244
|
+
* @description - Responsible for evaluation
|
|
245
|
+
* @param {function} func - Evaluative function
|
|
246
|
+
* @param {Any} value - The value to evaluate
|
|
247
|
+
* @param {function} done - Function to be executed in case the evaluation is positive.
|
|
248
|
+
* @param {function} reject - Function to be executed in case the evaluation is negative.
|
|
249
|
+
* @return {boolean} - value of the evaluation
|
|
250
|
+
*/
|
|
251
|
+
baseEvaluate = (func , value , done , reject) => {
|
|
252
|
+
const evaluate = func(value);
|
|
253
|
+
return evaluate ? isFunction( done ) ? baseSanetize(done,value,evaluate) : true : isFunction( reject ) ? baseSanetize(reject,value,evaluate) : false ;
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* @function base
|
|
257
|
+
* @description - This function stretches to baseEvaluate passing as parameter the function that specifically evaluates the given value to be evaluated, but in the baseEvaluate function it arrives as a parameter called func
|
|
258
|
+
* @param {function} func - Evaluative function
|
|
259
|
+
* @return {function} - function to execute baseEvaluate
|
|
260
|
+
* @example
|
|
261
|
+
* const hello = "hello Word!";
|
|
262
|
+
* const evaluate = base(isString)(hello)
|
|
263
|
+
* //return true
|
|
264
|
+
*/
|
|
265
|
+
base = ( func ) => ( value ,done , reject) => baseEvaluate( func , value , done , reject),
|
|
266
|
+
/**
|
|
267
|
+
* @description - Obtains the object to be exported with the following main functions
|
|
268
|
+
* @name is
|
|
269
|
+
* @type {object}
|
|
270
|
+
* @property {function} isArray - {@link isArray}
|
|
271
|
+
* @property {function} isBoolean - {@link isBoolean}
|
|
272
|
+
* @property {function} isDate - {@link isDate}
|
|
273
|
+
* @property {function} isElement - {@link isElement}
|
|
274
|
+
* @property {function} isEmpty - {@link isEmpty}
|
|
275
|
+
* @property {function} isFunction - {@link isFunction}
|
|
276
|
+
* @property {function} isNull - {@link isNull}
|
|
277
|
+
* @property {function} isNumber - {@link isNumber}
|
|
278
|
+
* @property {function} isString - {@link isString}
|
|
279
|
+
* @property {function} isUndefined - {@link isUndefined}
|
|
280
|
+
* @property {function} isEmail - {@link isEmail}
|
|
281
|
+
* @property {function} isNaN - {@link isNaN}
|
|
282
|
+
* @property {function} isRegExp - {@link isRegExp}
|
|
283
|
+
* @property {function} isUrl - {@link isUrl}
|
|
284
|
+
* @property {function} isNodeList - {@link isNodeList}
|
|
285
|
+
* @property {function} isHTMLCollection - {@link isHTMLCollection}
|
|
286
|
+
* @property {function} isAMD - {@link isAMD}
|
|
287
|
+
* @property {function} isFreeModule - {@link isFreeModule}
|
|
288
|
+
* @property {function} getRoot - {@link getRoot}
|
|
289
|
+
*/
|
|
290
|
+
is = {
|
|
291
|
+
'isArray':base(isArray),
|
|
292
|
+
'isBoolean':base(isBoolean),
|
|
293
|
+
'isDate':base(isDate),
|
|
294
|
+
'isElement':base(isElement),
|
|
295
|
+
'isEmpty':base(isEmpty),
|
|
296
|
+
'isFunction':base(isFunction),
|
|
297
|
+
'isNull':base(isNull),
|
|
298
|
+
'isNumber':base(isNumber),
|
|
299
|
+
'isObject':base(isObject),
|
|
300
|
+
'isString':base(isString),
|
|
301
|
+
'isUndefined':base(isUndefined),
|
|
302
|
+
'isEmail':base(isEmail),
|
|
303
|
+
'isNaN':base(isNaN),
|
|
304
|
+
'isRegExp':base(isRegExp),
|
|
305
|
+
'isUrl':base(isUrl),
|
|
306
|
+
'isNodeList':base(isNodeList),
|
|
307
|
+
'isHTMLCollection':base(isHTMLCollection),
|
|
308
|
+
'isAMD':base(isAMD),
|
|
309
|
+
'isFreeModule':base(isFreeModule),
|
|
310
|
+
'getRoot':getRoot
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
//
|
|
315
|
+
is.isAMD(null,()=>{define(()=>is)},()=>{
|
|
316
|
+
is.isFreeModule(null,()=>{ module.exports = is; },()=>{
|
|
317
|
+
is.getRoot().ppIs = is
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
}.call(this))
|
package/pp-is.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/*!!
|
|
2
|
-
* Power Panel pp-is <https://github.com/carlos-sweb/pp-is>
|
|
3
|
-
* @author Carlos Illesca
|
|
4
|
-
* @version 1.2.1 (2024/02/26 15:00 PM)
|
|
5
|
-
* Released under the MIT License
|
|
6
|
-
*/
|
|
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)
|
|
55
|
-
}
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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);
|