pp-is 1.2.6 โ†’ 1.3.0

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
@@ -1,164 +1,313 @@
1
- # pp-is
1
+ # ๐Ÿงช pp-is
2
2
 
3
- ## Getting Started
3
+ > ๐Ÿ”Ž Tiny, fast, zero-dependency type checking for JavaScript.
4
4
 
5
- In the web project include pp-is.js with:
5
+ [![npm version](https://img.shields.io/npm/v/pp-is.svg)](https://www.npmjs.com/package/pp-is)
6
+ [![license](https://img.shields.io/npm/l/pp-is.svg)](./LICENSE.txt)
7
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/pp-is)](https://bundlephobia.com/package/pp-is)
6
8
 
7
- ```html
8
- <script src="https://cdn.jsdelivr.net/npm/pp-is@1.2.5/pp-is.min.js" ></script>
9
+ **43 functions** to validate everything โ€” from primitives to DOM, emails to UUIDs. Zero dependencies. Works everywhere.
10
+
11
+ ```js
12
+ ppIs.isEmail('hello@world.com') // โœ… true
13
+ ppIs.isInteger(42) // โœ… true
14
+ ppIs.isUUID('550e8400-e29b...') // โœ… true
15
+ ppIs.isAlpha('Hello') // โœ… true
9
16
  ```
10
17
 
11
- Or
18
+ ---
19
+
20
+ ## โšก Quick Start
12
21
 
13
- ## Install
22
+ ### ๐Ÿ“ฆ Install
14
23
 
15
- ```console
16
- npm i pp-is --save
24
+ ```bash
25
+ npm i pp-is
17
26
  ```
18
- ## Methods
19
27
 
20
- #### `isArray`
28
+ ### ๐ŸŒ CDN
21
29
 
22
- Checks if value is classified as an Array object.
30
+ ```html
31
+ <script src="https://cdn.jsdelivr.net/npm/pp-is@1.3.0/pp-is.min.js"></script>
32
+ ```
23
33
 
24
- ---
25
- #### `isBoolean`
34
+ ### ๐Ÿš€ First Use
26
35
 
27
- Checks if value is either true or false.
36
+ ```html
37
+ <script src="https://cdn.jsdelivr.net/npm/pp-is@1.3.0/pp-is.min.js"></script>
38
+ <script>
39
+ // ppIs is available globally
40
+ if (ppIs.isEmail(document.getElementById('email').value)) {
41
+ console.log('Valid email!')
42
+ }
43
+ </script>
44
+ ```
28
45
 
29
- ---
30
- #### `isDate`
46
+ ```js
47
+ // Or as ES module
48
+ import ppIs from 'pp-is'
31
49
 
32
- Checks if value is a Date
50
+ ppIs.isString('hello') // true
51
+ ppIs.isNull(null) // true
52
+ ```
33
53
 
34
54
  ---
35
- #### `isElement`
36
55
 
37
- Checks if value is a DOM element.
56
+ ## ๐ŸŽฏ Why pp-is?
38
57
 
39
- ---
40
- #### `isFunction`
41
-
42
- Checks if value is a Function.
58
+ | Feature | pp-is | lodash | validator.js |
59
+ |---------|:-----:|:------:|:------------:|
60
+ | Bundle size (min+gz) | **~2KB** | ~7KB | ~30KB |
61
+ | Zero dependencies | โœ… | โœ… | โŒ |
62
+ | Callback system | โœ… | โŒ | โŒ |
63
+ | DOM checks | โœ… | โŒ | โŒ |
64
+ | ES Modules | โœ… | partial | โŒ |
65
+ | TypeScript friendly | โœ… | โœ… | โœ… |
66
+ | Functions count | **43** | ~15 | ~50 |
43
67
 
44
68
  ---
45
- #### `isNull`
46
69
 
47
- Checks if value is a Null.
70
+ ## ๐Ÿ“ฆ What's Inside?
48
71
 
49
- ---
50
- #### `isNumber`
51
-
52
- Checks if value is a Number.
72
+ | Category | Functions | What it covers |
73
+ |----------|-----------|----------------|
74
+ | ๐Ÿงฑ **Primitives** | `isArray` `isString` `isNumber` `isBoolean` `isFunction` `isObject` `isDate` `isNull` `isUndefined` `isRegExp` `isPromise` `isSymbol` `isBigInt` | Type checks for all JS primitives |
75
+ | ๐Ÿ”ข **Numbers** | `isInteger` `isFinite` `isPositive` `isNegative` `isNaN` | Numeric validation |
76
+ | ๐Ÿ“ **Strings** | `isAlpha` `isAlphanumeric` `isNumericString` `isLowercase` `isUppercase` `isBlank` | String content checks |
77
+ | ๐ŸŒ **Format** | `isEmail` `isUrl` `isJSON` `isUUID` `isIPv4` `isHexColor` | Format validation with regex |
78
+ | โš™๏ธ **Behavior** | `isIterable` `isTruthy` `isFalsy` `isCallable` `isAsyncFunction` `isPromiseLike` | Runtime behavior checks |
79
+ | ๐Ÿ  **DOM** | `isElement` `isNodeList` `isHTMLCollection` | Browser DOM nodes |
80
+ | ๐Ÿงฉ **Composition** | `isNil` `isEmpty` | Combine multiple checks |
81
+ | ๐Ÿ”’ **Object State** | `isFrozen` `isSealed` | Object mutability checks |
53
82
 
54
83
  ---
55
- #### `isObject`
56
84
 
57
- Checks if value is classified as an Object.
85
+ ## ๐Ÿ” API Reference
86
+
87
+ ### ๐Ÿงฑ Primitives
88
+
89
+ | Function | Description | Example |
90
+ |----------|-------------|---------|
91
+ | `isArray(value)` | Is it an array? | `ppIs.isArray([1,2]) โ†’ true` |
92
+ | `isString(value)` | Is it a string? | `ppIs.isString('hi') โ†’ true` |
93
+ | `isNumber(value)` | Is it a number (not NaN)? | `ppIs.isNumber(42) โ†’ true` |
94
+ | `isBoolean(value)` | Is it true, false, or a Boolean? | `ppIs.isBoolean(true) โ†’ true` |
95
+ | `isFunction(value)` | Is it a function? | `ppIs.isFunction(()=>{}) โ†’ true` |
96
+ | `isObject(value)` | Is it a plain object? | `ppIs.isObject({}) โ†’ true` |
97
+ | `isDate(value)` | Is it a Date instance? | `ppIs.isDate(new Date()) โ†’ true` |
98
+ | `isNull(value)` | Is it null? | `ppIs.isNull(null) โ†’ true` |
99
+ | `isUndefined(value)` | Is it undefined? | `ppIs.isUndefined(undefined) โ†’ true` |
100
+ | `isRegExp(value)` | Is it a RegExp? | `ppIs.isRegExp(/abc/) โ†’ true` |
101
+ | `isPromise(value)` | Is it a Promise? | `ppIs.isPromise(Promise.resolve()) โ†’ true` |
102
+ | `isSymbol(value)` | Is it a Symbol? | `ppIs.isSymbol(Symbol('x')) โ†’ true` |
103
+ | `isBigInt(value)` | Is it a BigInt? | `ppIs.isBigInt(42n) โ†’ true` |
58
104
 
59
105
  ---
60
- #### `isString`
61
106
 
62
- Checks if value is a string.
107
+ ### ๐Ÿ”ข Numbers
108
+
109
+ | Function | Description | Example |
110
+ |----------|-------------|---------|
111
+ | `isInteger(value)` | Is it an integer? | `ppIs.isInteger(42) โ†’ true` |
112
+ | `isFinite(value)` | Is it finite (not Infinity)? | `ppIs.isFinite(42) โ†’ true` |
113
+ | `isPositive(value)` | Is it greater than zero? | `ppIs.isPositive(5) โ†’ true` |
114
+ | `isNegative(value)` | Is it less than zero? | `ppIs.isNegative(-5) โ†’ true` |
115
+ | `isNaN(value)` | Can it NOT be parsed as integer? | `ppIs.isNaN('abc') โ†’ true` |
63
116
 
64
117
  ---
65
- #### `isUndefined`
66
118
 
67
- Checks if value is a undefined.
119
+ ### ๐Ÿ“ Strings
120
+
121
+ | Function | Description | Example |
122
+ |----------|-------------|---------|
123
+ | `isAlpha(value)` | Only letters (a-z, A-Z)? | `ppIs.isAlpha('Hello') โ†’ true` |
124
+ | `isAlphanumeric(value)` | Letters and numbers only? | `ppIs.isAlphanumeric('abc123') โ†’ true` |
125
+ | `isNumericString(value)` | Digits only (0-9)? | `ppIs.isNumericString('12345') โ†’ true` |
126
+ | `isLowercase(value)` | All lowercase? | `ppIs.isLowercase('hello') โ†’ true` |
127
+ | `isUppercase(value)` | All uppercase? | `ppIs.isUppercase('HELLO') โ†’ true` |
128
+ | `isBlank(value)` | Empty or whitespace only? | `ppIs.isBlank(' ') โ†’ true` |
129
+ | `isEmpty(value)` | Empty string, array, or object? | `ppIs.isEmpty('') โ†’ true` |
68
130
 
69
131
  ---
70
- #### `isEmail`
71
132
 
72
- Checks if value is a valid email.
133
+ ### ๐ŸŒ Format Validation
73
134
 
74
- ---
135
+ | Function | Description | Example |
136
+ |----------|-------------|---------|
137
+ | `isEmail(value)` | Valid email address? | `ppIs.isEmail('a@b.com') โ†’ true` |
138
+ | `isUrl(value)` | Valid URL? | `ppIs.isUrl('https://google.com') โ†’ true` |
139
+ | `isJSON(value)` | Valid JSON string? | `ppIs.isJSON('{"a":1}') โ†’ true` |
140
+ | `isUUID(value)` | Valid UUID (v1-v5)? | `ppIs.isUUID('550e8400-e29b-41d4-a716-446655440000') โ†’ true` |
141
+ | `isIPv4(value)` | Valid IPv4 address? | `ppIs.isIPv4('192.168.1.1') โ†’ true` |
142
+ | `isHexColor(value)` | Valid hex color? | `ppIs.isHexColor('#FF5733') โ†’ true` |
75
143
 
76
144
  ---
77
- #### `isNaN`
78
145
 
79
- Checks if value is a valid Number from String.
146
+ ### โš™๏ธ Behavior
80
147
 
81
- ---
148
+ | Function | Description | Example |
149
+ |----------|-------------|---------|
150
+ | `isIterable(value)` | Has Symbol.iterator? | `ppIs.isIterable([1,2]) โ†’ true` |
151
+ | `isTruthy(value)` | Is truthy? | `ppIs.isTruthy(1) โ†’ true` |
152
+ | `isFalsy(value)` | Is falsy? | `ppIs.isFalsy(0) โ†’ true` |
153
+ | `isCallable(value)` | Can be invoked as function? | `ppIs.isCallable(()=>{}) โ†’ true` |
154
+ | `isAsyncFunction(value)` | Is an async function? | `ppIs.isAsyncFunction(async()=>{}) โ†’ true` |
155
+ | `isPromiseLike(value)` | Is Promise or thenable? | `ppIs.isPromiseLike({then:()=>{}}) โ†’ true` |
82
156
 
83
157
  ---
84
- #### `isRegExp`
85
158
 
86
- Checks if value is a RegExp.
159
+ ### ๐Ÿ  DOM
87
160
 
88
- ---
161
+ | Function | Description | Example |
162
+ |----------|-------------|---------|
163
+ | `isElement(value)` | Is a DOM element (nodeType === 1)? | `ppIs.isElement(document.body) โ†’ true` |
164
+ | `isNodeList(value)` | Is a NodeList? | `ppIs.isNodeList(document.querySelectorAll('div')) โ†’ true` |
165
+ | `isHTMLCollection(value)` | Is an HTMLCollection? | `ppIs.isHTMLCollection(document.getElementsByClassName('x')) โ†’ true` |
89
166
 
90
167
  ---
91
- #### `isUrl`
92
168
 
93
- Checks if value is a valid Url.
169
+ ### ๐Ÿงฉ Composition
170
+
171
+ | Function | Description | Example |
172
+ |----------|-------------|---------|
173
+ | `isNil(value)` | Is null or undefined? | `ppIs.isNil(null) โ†’ true` |
94
174
 
95
175
  ---
96
176
 
97
- #### `isNodeList`
177
+ ### ๐Ÿ”’ Object State
98
178
 
99
- Checks if value is a valid NodeList.
179
+ | Function | Description | Example |
180
+ |----------|-------------|---------|
181
+ | `isFrozen(value)` | Is a frozen object? | `ppIs.isFrozen(Object.freeze({})) โ†’ true` |
182
+ | `isSealed(value)` | Is a sealed object? | `ppIs.isSealed(Object.seal({})) โ†’ true` |
100
183
 
101
184
  ---
102
185
 
103
- #### `isHTMLCollection`
186
+ ## ๐Ÿช Callback System
104
187
 
105
- Checks if value is a valid HTMLCollection.
188
+ Every function supports **optional `done` and `reject` callbacks** for extra validation. This is what makes pp-is unique.
106
189
 
107
- ---
190
+ ```js
191
+ ppIs.isString(value, done?, reject?)
192
+ ```
108
193
 
109
- #### `isEmpty`
194
+ - **`done`** โ€” runs when the check passes. Return `true`/`false` to override.
195
+ - **`reject`** โ€” runs when the check fails. Return `true`/`false` to override.
110
196
 
111
- Verify that a value is not empty, in the case of a string that is not โ€œโ€ , in the case of an array that is not \[\] and an object that is not {}.
197
+ ### Example: Basic
112
198
 
113
- ---
199
+ ```js
200
+ ppIs.isString('hello')
201
+ // โ†’ true
202
+ ```
114
203
 
115
- #### `isBlank`
204
+ ### Example: Extra validation
116
205
 
117
- Check that a value is blank, which is when a string is not empty but filled with blank spaces.
206
+ ```js
207
+ const result = ppIs.isString(
208
+ 'hello',
209
+ (val) => val.length > 3, // done: also check length
210
+ (val) => false // reject: always false on fail
211
+ )
212
+ // โ†’ true (it's a string AND length > 3)
213
+ ```
118
214
 
119
- ---
215
+ ### Example: Real-world form validation
120
216
 
121
- #### `isPromise`
217
+ ```js
218
+ function validateEmail(input) {
219
+ return ppIs.isEmail(input,
220
+ (val) => val.includes('@company.com'), // must be company email
221
+ () => { showError('Invalid email'); return false }
222
+ )
223
+ }
122
224
 
123
- Checks if value is classified as an Promise object.
225
+ validateEmail('john@company.com') // โœ… true
226
+ validateEmail('john@gmail.com') // โŒ false (not company domain)
227
+ ```
124
228
 
125
229
  ---
126
230
 
127
- ## How to use ?
231
+ ## ๐Ÿ› ๏ธ TypeScript
128
232
 
129
- ```javascript
233
+ pp-is is written in vanilla JavaScript but works great with TypeScript:
130
234
 
131
- var value = "string...";
235
+ ```ts
236
+ import ppIs from 'pp-is'
132
237
 
133
- if( ppIs.isString(value) ){
134
- // Enter your code here
238
+ function processUser(input: unknown) {
239
+ if (ppIs.isString(input)) {
240
+ // input is narrowed to string here โœ…
241
+ console.log(input.toUpperCase())
242
+ }
243
+
244
+ if (ppIs.isEmail(input)) {
245
+ // input is validated as email format โœ…
246
+ sendWelcome(input)
247
+ }
135
248
  }
136
249
  ```
137
250
 
138
- ### or
139
-
251
+ ---
140
252
 
253
+ ## ๐Ÿงฌ How It Works
141
254
 
142
- ```javascript
143
- // You can make an extra evaluation
144
- const done = ( value ) => {
145
- return value !== 'string';
146
- }
255
+ Under the hood, pp-is uses `Object.prototype.toString.call()` for accurate type detection, wrapped in a callback system that gives you full control:
147
256
 
148
- const reject = ( value ) => {
149
-
150
- }
257
+ ```
258
+ ppIs.isString(value, done, reject)
259
+ โ”‚ โ”‚ โ”‚
260
+ โ–ผ โ–ผ โ–ผ
261
+ getTypeCompare callback callback
262
+ (type check) (on pass) (on fail)
263
+ โ”‚ โ”‚ โ”‚
264
+ โ–ผ โ–ผ โ–ผ
265
+ true/false โ† baseEvaluate โ†’ true/false
266
+ ```
151
267
 
152
- const value = 'string';
268
+ ---
153
269
 
154
- const result = ppIs.isString( value , done , reject );
270
+ ## ๐Ÿค Contributing
271
+
272
+ Contributions are welcome! Here's how to get started:
273
+
274
+ 1. **Fork** the repository
275
+ 2. **Clone** your fork
276
+ ```bash
277
+ git clone https://github.com/YOUR_USERNAME/pp-is.git
278
+ cd pp-is
279
+ ```
280
+ 3. **Install** dependencies
281
+ ```bash
282
+ npm install
283
+ ```
284
+ 4. **Create** your function in `dist/main/yourFunction.js`
285
+ 5. **Add** it to `dist/pp-is.js` (import + add to `is` object)
286
+ 6. **Build** to verify
287
+ ```bash
288
+ npm run build
289
+ ```
290
+ 7. **Test** your function
291
+ ```bash
292
+ node -e "const ppIs = require('./dist/pp-is.min.js'); console.log(ppIs.yourFunction('test'))"
293
+ ```
294
+ 8. **Submit** a pull request
295
+
296
+ ### ๐Ÿ“‹ Guidelines
297
+
298
+ - One function per file in `dist/main/`
299
+ - Use `export { funcName as default }`
300
+ - Add JSDoc comments (`@function`, `@description`, `@param`, `@return`)
301
+ - Wrap with `base()` for callback support
302
+ - Keep it **zero dependencies**
303
+ - Follow existing code style (arrow functions, no semicolons)
155
304
 
156
- if( result ){
305
+ ---
157
306
 
158
- }else{
307
+ ## ๐Ÿ“„ License
159
308
 
160
- }
309
+ [MIT](./LICENSE.txt) โ€” Carlos Illesca
161
310
 
162
- ```
311
+ ---
163
312
 
164
- [Lea este documento en espaรฑol](./README_es.md)
313
+ [๐Ÿ“„ Espaรฑol](./README_es.md)
package/README_es.md CHANGED
@@ -1,164 +1,313 @@
1
- # pp-is
1
+ # ๐Ÿงช pp-is
2
2
 
3
- ## Para empezar
3
+ > ๐Ÿ”Ž Verificaciรณn de tipos rรกpida, ligera y sin dependencias para JavaScript.
4
4
 
5
- Incluye pp-is.js en tu proyecto web:
6
- ```html
7
- <script src="https://cdn.jsdelivr.net/npm/pp-is@1.2.5/pp-is.min.js" ></script>
5
+ [![versiรณn npm](https://img.shields.io/npm/v/pp-is.svg)](https://www.npmjs.com/package/pp-is)
6
+ [![licencia](https://img.shields.io/npm/l/pp-is.svg)](./LICENSE.txt)
7
+ [![tamaรฑo del bundle](https://img.shields.io/bundlephobia/minzip/pp-is)](https://bundlephobia.com/package/pp-is)
8
+
9
+ **43 funciones** para validar todo โ€” desde primitivos hasta DOM, emails hasta UUIDs. Cero dependencias. Funciona en todas partes.
10
+
11
+ ```js
12
+ ppIs.isEmail('hola@mundo.com') // โœ… true
13
+ ppIs.isInteger(42) // โœ… true
14
+ ppIs.isUUID('550e8400-e29b...') // โœ… true
15
+ ppIs.isAlpha('Hola') // โœ… true
8
16
  ```
9
17
 
10
- O
18
+ ---
19
+
20
+ ## โšก Inicio Rรกpido
11
21
 
12
- ## Instalaciรณn
22
+ ### ๐Ÿ“ฆ Instalaciรณn
13
23
 
14
- ```console
15
- npm i pp-is --save
24
+ ```bash
25
+ npm i pp-is
16
26
  ```
17
- ## Metodos
18
27
 
19
- #### `isArray`
28
+ ### ๐ŸŒ CDN
20
29
 
21
- Verifica si el valor es clasificado como un Objecto de Array.
30
+ ```html
31
+ <script src="https://cdn.jsdelivr.net/npm/pp-is@1.3.0/pp-is.min.js"></script>
32
+ ```
22
33
 
23
- ---
24
- #### `isBoolean`
34
+ ### ๐Ÿš€ Primer Uso
25
35
 
26
- Verifica si el valor is verdadero ( true ) o falso ( false ).
36
+ ```html
37
+ <script src="https://cdn.jsdelivr.net/npm/pp-is@1.3.0/pp-is.min.js"></script>
38
+ <script>
39
+ // ppIs estรก disponible globalmente
40
+ if (ppIs.isEmail(document.getElementById('email').value)) {
41
+ console.log('ยกEmail vรกlido!')
42
+ }
43
+ </script>
44
+ ```
27
45
 
28
- ---
29
- #### `isDate`
46
+ ```js
47
+ // O como mรณdulo ES
48
+ import ppIs from 'pp-is'
30
49
 
31
- Verifica si el valor es una Fecha.
50
+ ppIs.isString('hola') // true
51
+ ppIs.isNull(null) // true
52
+ ```
32
53
 
33
54
  ---
34
- #### `isElement`
35
55
 
36
- verifica si el valor es un elemento del DOM
56
+ ## ๐ŸŽฏ ยฟPor quรฉ pp-is?
37
57
 
58
+ | Caracterรญstica | pp-is | lodash | validator.js |
59
+ |----------------|:-----:|:------:|:------------:|
60
+ | Tamaรฑo del bundle (min+gz) | **~2KB** | ~7KB | ~30KB |
61
+ | Cero dependencias | โœ… | โœ… | โŒ |
62
+ | Sistema de callbacks | โœ… | โŒ | โŒ |
63
+ | Verificaciones DOM | โœ… | โŒ | โŒ |
64
+ | ES Modules | โœ… | parcial | โŒ |
65
+ | Compatible con TypeScript | โœ… | โœ… | โœ… |
66
+ | Cantidad de funciones | **43** | ~15 | ~50 |
38
67
 
39
68
  ---
40
- #### `isFunction`
41
-
42
- Verifica si el valor es una funciรณn
43
69
 
44
- ---
45
- #### `isNull`
70
+ ## ๐Ÿ“ฆ ยฟQuรฉ incluye?
46
71
 
47
- Verifica si el valor es un nulo.
72
+ | Categorรญa | Funciones | Quรฉ cubre |
73
+ |-----------|-----------|-----------|
74
+ | ๐Ÿงฑ **Primitivos** | `isArray` `isString` `isNumber` `isBoolean` `isFunction` `isObject` `isDate` `isNull` `isUndefined` `isRegExp` `isPromise` `isSymbol` `isBigInt` | Verificaciones de tipo para todos los primitivos JS |
75
+ | ๐Ÿ”ข **Nรบmeros** | `isInteger` `isFinite` `isPositive` `isNegative` `isNaN` | Validaciรณn numรฉrica |
76
+ | ๐Ÿ“ **Strings** | `isAlpha` `isAlphanumeric` `isNumericString` `isLowercase` `isUppercase` `isBlank` | Verificaciones de contenido de strings |
77
+ | ๐ŸŒ **Formato** | `isEmail` `isUrl` `isJSON` `isUUID` `isIPv4` `isHexColor` | Validaciรณn de formato con regex |
78
+ | โš™๏ธ **Comportamiento** | `isIterable` `isTruthy` `isFalsy` `isCallable` `isAsyncFunction` `isPromiseLike` | Verificaciones de comportamiento en tiempo de ejecuciรณn |
79
+ | ๐Ÿ  **DOM** | `isElement` `isNodeList` `isHTMLCollection` | Nodos del DOM del navegador |
80
+ | ๐Ÿงฉ **Composiciรณn** | `isNil` `isEmpty` | Combinar mรบltiples verificaciones |
81
+ | ๐Ÿ”’ **Estado del Objeto** | `isFrozen` `isSealed` | Verificaciones de mutabilidad de objetos |
48
82
 
49
83
  ---
50
- #### `isNumber`
51
84
 
52
- Verifica si el valor es un numero.
85
+ ## ๐Ÿ” Referencia de API
86
+
87
+ ### ๐Ÿงฑ Primitivos
88
+
89
+ | Funciรณn | Descripciรณn | Ejemplo |
90
+ |---------|-------------|---------|
91
+ | `isArray(value)` | ยฟEs un array? | `ppIs.isArray([1,2]) โ†’ true` |
92
+ | `isString(value)` | ยฟEs un string? | `ppIs.isString('hola') โ†’ true` |
93
+ | `isNumber(value)` | ยฟEs un nรบmero (no NaN)? | `ppIs.isNumber(42) โ†’ true` |
94
+ | `isBoolean(value)` | ยฟEs true, false, o un Boolean? | `ppIs.isBoolean(true) โ†’ true` |
95
+ | `isFunction(value)` | ยฟEs una funciรณn? | `ppIs.isFunction(()=>{}) โ†’ true` |
96
+ | `isObject(value)` | ยฟEs un objeto plano? | `ppIs.isObject({}) โ†’ true` |
97
+ | `isDate(value)` | ยฟEs una instancia de Date? | `ppIs.isDate(new Date()) โ†’ true` |
98
+ | `isNull(value)` | ยฟEs null? | `ppIs.isNull(null) โ†’ true` |
99
+ | `isUndefined(value)` | ยฟEs undefined? | `ppIs.isUndefined(undefined) โ†’ true` |
100
+ | `isRegExp(value)` | ยฟEs un RegExp? | `ppIs.isRegExp(/abc/) โ†’ true` |
101
+ | `isPromise(value)` | ยฟEs un Promise? | `ppIs.isPromise(Promise.resolve()) โ†’ true` |
102
+ | `isSymbol(value)` | ยฟEs un Symbol? | `ppIs.isSymbol(Symbol('x')) โ†’ true` |
103
+ | `isBigInt(value)` | ยฟEs un BigInt? | `ppIs.isBigInt(42n) โ†’ true` |
53
104
 
54
105
  ---
55
- #### `isObject`
56
106
 
57
- verifica si el valor es clasificado como un objecto.
58
-
59
- ---
60
- #### `isString`
107
+ ### ๐Ÿ”ข Nรบmeros
61
108
 
62
- Varifica si el valor es una cadena de texto.
109
+ | Funciรณn | Descripciรณn | Ejemplo |
110
+ |---------|-------------|---------|
111
+ | `isInteger(value)` | ยฟEs un entero? | `ppIs.isInteger(42) โ†’ true` |
112
+ | `isFinite(value)` | ยฟEs finito (no Infinity)? | `ppIs.isFinite(42) โ†’ true` |
113
+ | `isPositive(value)` | ยฟEs mayor que cero? | `ppIs.isPositive(5) โ†’ true` |
114
+ | `isNegative(value)` | ยฟEs menor que cero? | `ppIs.isNegative(-5) โ†’ true` |
115
+ | `isNaN(value)` | ยฟNO se puede parsear como entero? | `ppIs.isNaN('abc') โ†’ true` |
63
116
 
64
117
  ---
65
- #### `isUndefined`
66
118
 
67
- verifica si el valor esta no definido.
119
+ ### ๐Ÿ“ Strings
120
+
121
+ | Funciรณn | Descripciรณn | Ejemplo |
122
+ |---------|-------------|---------|
123
+ | `isAlpha(value)` | ยฟSolo letras (a-z, A-Z)? | `ppIs.isAlpha('Hola') โ†’ true` |
124
+ | `isAlphanumeric(value)` | ยฟSolo letras y nรบmeros? | `ppIs.isAlphanumeric('abc123') โ†’ true` |
125
+ | `isNumericString(value)` | ยฟSolo dรญgitos (0-9)? | `ppIs.isNumericString('12345') โ†’ true` |
126
+ | `isLowercase(value)` | ยฟTodo en minรบsculas? | `ppIs.isLowercase('hola') โ†’ true` |
127
+ | `isUppercase(value)` | ยฟTodo en mayรบsculas? | `ppIs.isUppercase('HOLA') โ†’ true` |
128
+ | `isBlank(value)` | ยฟVacรญo o solo espacios? | `ppIs.isBlank(' ') โ†’ true` |
129
+ | `isEmpty(value)` | ยฟString, array, o objeto vacรญo? | `ppIs.isEmpty('') โ†’ true` |
68
130
 
69
131
  ---
70
- #### `isEmail`
71
132
 
72
- Verifica si el valor es un correo electronico valido.
133
+ ### ๐ŸŒ Validaciรณn de Formato
73
134
 
74
- ---
135
+ | Funciรณn | Descripciรณn | Ejemplo |
136
+ |---------|-------------|---------|
137
+ | `isEmail(value)` | ยฟEmail vรกlido? | `ppIs.isEmail('a@b.com') โ†’ true` |
138
+ | `isUrl(value)` | ยฟURL vรกlida? | `ppIs.isUrl('https://google.com') โ†’ true` |
139
+ | `isJSON(value)` | ยฟString JSON vรกlido? | `ppIs.isJSON('{"a":1}') โ†’ true` |
140
+ | `isUUID(value)` | ยฟUUID vรกlido (v1-v5)? | `ppIs.isUUID('550e8400-e29b-41d4-a716-446655440000') โ†’ true` |
141
+ | `isIPv4(value)` | ยฟDirecciรณn IPv4 vรกlida? | `ppIs.isIPv4('192.168.1.1') โ†’ true` |
142
+ | `isHexColor(value)` | ยฟColor hexadecimal vรกlido? | `ppIs.isHexColor('#FF5733') โ†’ true` |
75
143
 
76
144
  ---
77
- #### `isNaN`
78
145
 
79
- Verifica si el valor es un numero valido proveniente de una cadena de texto.
146
+ ### โš™๏ธ Comportamiento
80
147
 
81
- ---
148
+ | Funciรณn | Descripciรณn | Ejemplo |
149
+ |---------|-------------|---------|
150
+ | `isIterable(value)` | ยฟTiene Symbol.iterator? | `ppIs.isIterable([1,2]) โ†’ true` |
151
+ | `isTruthy(value)` | ยฟEs truthy? | `ppIs.isTruthy(1) โ†’ true` |
152
+ | `isFalsy(value)` | ยฟEs falsy? | `ppIs.isFalsy(0) โ†’ true` |
153
+ | `isCallable(value)` | ยฟSe puede invocar como funciรณn? | `ppIs.isCallable(()=>{}) โ†’ true` |
154
+ | `isAsyncFunction(value)` | ยฟEs una funciรณn asรญncrona? | `ppIs.isAsyncFunction(async()=>{}) โ†’ true` |
155
+ | `isPromiseLike(value)` | ยฟEs Promise o thenable? | `ppIs.isPromiseLike({then:()=>{}}) โ†’ true` |
82
156
 
83
157
  ---
84
- #### `isRegExp`
85
158
 
86
- Verifica si el valor es una expresion regular
159
+ ### ๐Ÿ  DOM
87
160
 
88
- ---
161
+ | Funciรณn | Descripciรณn | Ejemplo |
162
+ |---------|-------------|---------|
163
+ | `isElement(value)` | ยฟEs un elemento DOM (nodeType === 1)? | `ppIs.isElement(document.body) โ†’ true` |
164
+ | `isNodeList(value)` | ยฟEs un NodeList? | `ppIs.isNodeList(document.querySelectorAll('div')) โ†’ true` |
165
+ | `isHTMLCollection(value)` | ยฟEs un HTMLCollection? | `ppIs.isHTMLCollection(document.getElementsByClassName('x')) โ†’ true` |
89
166
 
90
167
  ---
91
- #### `isUrl`
92
168
 
93
- Verifica si el valor es una url valida.
169
+ ### ๐Ÿงฉ Composiciรณn
170
+
171
+ | Funciรณn | Descripciรณn | Ejemplo |
172
+ |---------|-------------|---------|
173
+ | `isNil(value)` | ยฟEs null o undefined? | `ppIs.isNil(null) โ†’ true` |
94
174
 
95
175
  ---
96
176
 
97
- #### `isNodeList`
177
+ ### ๐Ÿ”’ Estado del Objeto
98
178
 
99
- Verifica si el valor es un NodeList valido.
179
+ | Funciรณn | Descripciรณn | Ejemplo |
180
+ |---------|-------------|---------|
181
+ | `isFrozen(value)` | ยฟEs un objeto congelado? | `ppIs.isFrozen(Object.freeze({})) โ†’ true` |
182
+ | `isSealed(value)` | ยฟEs un objeto sellado? | `ppIs.isSealed(Object.seal({})) โ†’ true` |
100
183
 
101
184
  ---
102
185
 
103
- #### `isHTMLCollection`
186
+ ## ๐Ÿช Sistema de Callbacks
104
187
 
105
- Verifica si el valor es un HTTMLCollection valido.
188
+ Todas las funciones soportan **callbacks opcionales `done` y `reject`** para validaciรณn extra. Esto es lo que hace รบnico a pp-is.
106
189
 
107
- ---
190
+ ```js
191
+ ppIs.isString(value, done?, reject?)
192
+ ```
108
193
 
109
- #### `isEmpty`
194
+ - **`done`** โ€” se ejecuta cuando la verificaciรณn pasa. Retorna `true`/`false` para sobreescribir.
195
+ - **`reject`** โ€” se ejecuta cuando la verificaciรณn falla. Retorna `true`/`false` para sobreescribir.
110
196
 
111
- Verifica que un valor no este vacio , en caso de una cadena que sea distinta a "" , en caso de un arreglo que sea distinoto a [] y un objecto que sea distinto a {}
197
+ ### Ejemplo: Bรกsico
112
198
 
113
- ---
199
+ ```js
200
+ ppIs.isString('hola')
201
+ // โ†’ true
202
+ ```
114
203
 
115
- #### `isBlank`
204
+ ### Ejemplo: Validaciรณn extra
116
205
 
117
- Comprueba que un valor estรฉ en blanco, lo cual ocurre cuando una cadena no estรก vacรญa, sino que estรก llena de espacios en blanco.
206
+ ```js
207
+ const resultado = ppIs.isString(
208
+ 'hola',
209
+ (val) => val.length > 3, // done: tambiรฉn verificar longitud
210
+ (val) => false // reject: siempre false en fallo
211
+ )
212
+ // โ†’ true (es string Y longitud > 3)
213
+ ```
118
214
 
119
- ---
215
+ ### Ejemplo: Validaciรณn de formularios del mundo real
120
216
 
121
- #### `isPromise`
217
+ ```js
218
+ function validarEmail(input) {
219
+ return ppIs.isEmail(input,
220
+ (val) => val.includes('@empresa.com'), // debe ser email de la empresa
221
+ () => { mostrarError('Email invรกlido'); return false }
222
+ )
223
+ }
122
224
 
123
- Comprueba si el valor estรก clasificado como un objeto Promise.
225
+ validarEmail('juan@empresa.com') // โœ… true
226
+ validarEmail('juan@gmail.com') // โŒ false (no es dominio de la empresa)
227
+ ```
124
228
 
125
229
  ---
126
230
 
127
- ## ยฟ Como se usa ?
231
+ ## ๐Ÿ› ๏ธ TypeScript
128
232
 
129
- ```javascript
233
+ pp-is estรก escrito en JavaScript vanilla pero funciona genial con TypeScript:
130
234
 
131
- var value = "string...";
235
+ ```ts
236
+ import ppIs from 'pp-is'
132
237
 
133
- if( ppIs.isString(value) ){
134
- // Ingresa tu codigo aqui
238
+ function procesarUsuario(input: unknown) {
239
+ if (ppIs.isString(input)) {
240
+ // input se reduce a string aquรญ โœ…
241
+ console.log(input.toUpperCase())
242
+ }
243
+
244
+ if (ppIs.isEmail(input)) {
245
+ // input se valida como formato de email โœ…
246
+ enviarBienvenida(input)
247
+ }
135
248
  }
136
249
  ```
137
250
 
138
- ### or
139
-
251
+ ---
140
252
 
253
+ ## ๐Ÿงฌ Cรณmo Funciona
141
254
 
142
- ```javascript
143
- // Puedes hacer una evaluaciรณn extra
144
- const done = ( value ) => {
145
- return value !== 'string';
146
- }
255
+ Internamente, pp-is usa `Object.prototype.toString.call()` para detecciรณn precisa de tipos, envuelto en un sistema de callbacks que te da control total:
147
256
 
148
- const reject = ( value ) => {
149
-
150
- }
257
+ ```
258
+ ppIs.isString(value, done, reject)
259
+ โ”‚ โ”‚ โ”‚
260
+ โ–ผ โ–ผ โ–ผ
261
+ getTypeCompare callback callback
262
+ (verif. tipo) (al pasar) (al fallar)
263
+ โ”‚ โ”‚ โ”‚
264
+ โ–ผ โ–ผ โ–ผ
265
+ true/false โ† baseEvaluate โ†’ true/false
266
+ ```
151
267
 
152
- const value = 'string';
268
+ ---
153
269
 
154
- const result = ppIs.isString( value , done , reject );
270
+ ## ๐Ÿค Contribuir
271
+
272
+ ยกLas contribuciones son bienvenidas! Asรญ es como puedes empezar:
273
+
274
+ 1. **Haz fork** del repositorio
275
+ 2. **Clona** tu fork
276
+ ```bash
277
+ git clone https://github.com/TU_USERNAME/pp-is.git
278
+ cd pp-is
279
+ ```
280
+ 3. **Instala** las dependencias
281
+ ```bash
282
+ npm install
283
+ ```
284
+ 4. **Crea** tu funciรณn en `dist/main/tuFuncion.js`
285
+ 5. **Agrรฉcala** a `dist/pp-is.js` (import + agregar al objeto `is`)
286
+ 6. **Build** para verificar
287
+ ```bash
288
+ npm run build
289
+ ```
290
+ 7. **Prueba** tu funciรณn
291
+ ```bash
292
+ node -e "const ppIs = require('./dist/pp-is.min.js'); console.log(ppIs.tuFuncion('test'))"
293
+ ```
294
+ 8. **Envรญa** un pull request
295
+
296
+ ### ๐Ÿ“‹ Directrices
297
+
298
+ - Una funciรณn por archivo en `dist/main/`
299
+ - Usa `export { funcName as default }`
300
+ - Agrega comentarios JSDoc (`@function`, `@description`, `@param`, `@return`)
301
+ - Envuelve con `base()` para soporte de callbacks
302
+ - Mantรฉn **cero dependencias**
303
+ - Sigue el estilo de cรณdigo existente (arrow functions, sin punto y coma)
155
304
 
156
- if( result ){
305
+ ---
157
306
 
158
- }else{
307
+ ## ๐Ÿ“„ Licencia
159
308
 
160
- }
309
+ [MIT](./LICENSE.txt) โ€” Carlos Illesca
161
310
 
162
- ```
311
+ ---
163
312
 
164
- [Read this document in English](./README.md)
313
+ [๐Ÿ‡ฌ๐Ÿ‡ง English](./README.md)
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isAlpha
4
+ * @description - Checks if value is a string containing only letters (a-z, A-Z).
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isAlpha=(value)=>isString(value) ? /^[a-zA-Z]+$/.test(value) : false
9
+ export { isAlpha as default }
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isAlphanumeric
4
+ * @description - Checks if value is a string containing only letters and numbers.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isAlphanumeric=(value)=>isString(value) ? /^[a-zA-Z0-9]+$/.test(value) : false
9
+ export { isAlphanumeric as default }
@@ -0,0 +1,9 @@
1
+ import getTypeCompare from "./../helper/getTypeCompare.js"
2
+ /**
3
+ * @function isAsyncFunction
4
+ * @description - Checks if value is an async function.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isAsyncFunction=(value)=>getTypeCompare(value,"AsyncFunction")
9
+ export { isAsyncFunction as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isBigInt
3
+ * @description - Checks if value is a BigInt.
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isBigInt=(value)=>typeof value === "bigint"
8
+ export { isBigInt as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isCallable
3
+ * @description - Checks if value is callable (can be invoked as a function).
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isCallable=(value)=>typeof value==="function"
8
+ export { isCallable as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isFalsy
3
+ * @description - Checks if value is falsy.
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isFalsy=(value)=>!value
8
+ export { isFalsy as default }
@@ -0,0 +1,9 @@
1
+ import isNumber from "./isNumber.js"
2
+ /**
3
+ * @function isFinite
4
+ * @description - Checks if value is a finite number (not Infinity or -Infinity).
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isFinite=(value)=>isNumber(value) && Number.isFinite(value)
9
+ export { isFinite as default }
@@ -0,0 +1,9 @@
1
+ import isObject from "./isObject.js"
2
+ /**
3
+ * @function isFrozen
4
+ * @description - Checks if value is a frozen object.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isFrozen=(value)=>isObject(value) && Object.isFrozen(value)
9
+ export { isFrozen as default }
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isHexColor
4
+ * @description - Checks if value is a valid hexadecimal color string.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isHexColor=(value)=>isString(value) ? /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value) : false
9
+ export { isHexColor as default }
@@ -0,0 +1,18 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isIPv4
4
+ * @description - Checks if value is a valid IPv4 address.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isIPv4=(value)=>{
9
+ if(!isString(value)){return false}
10
+ const parts=value.split(".")
11
+ if(parts.length!==4){return false}
12
+ return parts.every((part)=>{
13
+ if(!/^[0-9]+$/.test(part)){return false}
14
+ const num=Number(part)
15
+ return num>=0 && num<=255 && String(num)===part
16
+ })
17
+ }
18
+ export { isIPv4 as default }
@@ -0,0 +1,9 @@
1
+ import isNumber from "./isNumber.js"
2
+ /**
3
+ * @function isInteger
4
+ * @description - Checks if value is an integer number.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isInteger=(value)=>isNumber(value) && Number.isInteger(value)
9
+ export { isInteger as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isIterable
3
+ * @description - Checks if value is iterable (has Symbol.iterator).
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isIterable=(value)=>value!=null && typeof value[Symbol.iterator]==="function"
8
+ export { isIterable as default }
@@ -0,0 +1,13 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isJSON
4
+ * @description - Checks if value is a valid JSON string.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isJSON=(value)=>{
9
+ if(!isString(value)){return false}
10
+ try{JSON.parse(value);return true}
11
+ catch(e){return false}
12
+ }
13
+ export { isJSON as default }
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isLowercase
4
+ * @description - Checks if value is a lowercase string.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isLowercase=(value)=>isString(value) ? value === value.toLowerCase() && value !== value.toUpperCase() : false
9
+ export { isLowercase as default }
@@ -0,0 +1,9 @@
1
+ import isNumber from "./isNumber.js"
2
+ /**
3
+ * @function isNegative
4
+ * @description - Checks if value is a negative number (less than zero).
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isNegative=(value)=>isNumber(value) && value < 0
9
+ export { isNegative as default }
@@ -0,0 +1,11 @@
1
+ import isUndefined from "./isUndefined.js"
2
+ import isNull from "./isNull.js"
3
+ /**
4
+ * @function isNil
5
+ * @description - Check that a value is undefined or null
6
+ * @param { Any } value - Any Value
7
+ * @return {boolean}
8
+ */
9
+
10
+ const isNil = (value)=>isUndefined(value)||isNull(value)
11
+ export { isNil as default }
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isNumericString
4
+ * @description - Checks if value is a string containing only digits (0-9).
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isNumericString=(value)=>isString(value) ? /^[0-9]+$/.test(value) : false
9
+ export { isNumericString as default }
@@ -0,0 +1,9 @@
1
+ import isNumber from "./isNumber.js"
2
+ /**
3
+ * @function isPositive
4
+ * @description - Checks if value is a positive number (greater than zero).
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isPositive=(value)=>isNumber(value) && value > 0
9
+ export { isPositive as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isPromiseLike
3
+ * @description - Checks if value is a Promise or thenable (has a .then method).
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isPromiseLike=(value)=>value!=null && typeof value.then==="function"
8
+ export { isPromiseLike as default }
@@ -0,0 +1,9 @@
1
+ import isObject from "./isObject.js"
2
+ /**
3
+ * @function isSealed
4
+ * @description - Checks if value is a sealed object.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isSealed=(value)=>isObject(value) && Object.isSealed(value)
9
+ export { isSealed as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isSymbol
3
+ * @description - Checks if value is a Symbol.
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isSymbol=(value)=>typeof value === "symbol"
8
+ export { isSymbol as default }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @function isTruthy
3
+ * @description - Checks if value is truthy.
4
+ * @param { Any } value - Any value
5
+ * @return {boolean}
6
+ */
7
+ const isTruthy=(value)=>!!value===true
8
+ export { isTruthy as default }
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isUUID
4
+ * @description - Checks if value is a valid UUID (v1-v5).
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isUUID=(value)=>isString(value) ? /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value) : false
9
+ export { isUUID as default }
@@ -0,0 +1,9 @@
1
+ import isString from "./isString.js"
2
+ /**
3
+ * @function isUppercase
4
+ * @description - Checks if value is an uppercase string.
5
+ * @param { Any } value - Any value
6
+ * @return {boolean}
7
+ */
8
+ const isUppercase=(value)=>isString(value) ? value === value.toUpperCase() && value !== value.toLowerCase() : false
9
+ export { isUppercase as default }
package/dist/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.2.6 (2025/06/02 21:43 PM)
4
+ * @version 1.3.0 (2026/07/14)
5
5
  * Released under the MIT License
6
6
  */
7
7
  import isPromise from "./main/isPromise.js"
@@ -15,6 +15,7 @@ import isDate from "./main/isDate.js"
15
15
  import isFunction from "./main/isFunction.js"
16
16
  import isUndefined from "./main/isUndefined.js"
17
17
  import isNull from "./main/isNull.js"
18
+ import isNil from "./main/isNil.js"
18
19
  import isNaN from "./main/isNaN.js"
19
20
  import isNumber from "./main/isNumber.js"
20
21
  import isEmail from "./main/isEmail.js"
@@ -23,6 +24,29 @@ import isEmpty from "./main/isEmpty.js"
23
24
  import isNodeList from "./main/isNodeList.js"
24
25
  import isElement from "./main/isElement.js"
25
26
  import isHTMLCollection from "./main/isHTMLCollection.js"
27
+ import isSymbol from "./main/isSymbol.js"
28
+ import isBigInt from "./main/isBigInt.js"
29
+ import isInteger from "./main/isInteger.js"
30
+ import isFinite from "./main/isFinite.js"
31
+ import isPositive from "./main/isPositive.js"
32
+ import isNegative from "./main/isNegative.js"
33
+ import isAlpha from "./main/isAlpha.js"
34
+ import isAlphanumeric from "./main/isAlphanumeric.js"
35
+ import isNumericString from "./main/isNumericString.js"
36
+ import isLowercase from "./main/isLowercase.js"
37
+ import isUppercase from "./main/isUppercase.js"
38
+ import isHexColor from "./main/isHexColor.js"
39
+ import isJSON from "./main/isJSON.js"
40
+ import isUUID from "./main/isUUID.js"
41
+ import isIPv4 from "./main/isIPv4.js"
42
+ import isIterable from "./main/isIterable.js"
43
+ import isTruthy from "./main/isTruthy.js"
44
+ import isFalsy from "./main/isFalsy.js"
45
+ import isCallable from "./main/isCallable.js"
46
+ import isAsyncFunction from "./main/isAsyncFunction.js"
47
+ import isPromiseLike from "./main/isPromiseLike.js"
48
+ import isFrozen from "./main/isFrozen.js"
49
+ import isSealed from "./main/isSealed.js"
26
50
  import base from "./helper/base.js"
27
51
  /**
28
52
  * @description - Obtains the object to be exported with the following main functions
@@ -44,9 +68,29 @@ import base from "./helper/base.js"
44
68
  * @property {function} isUrl - {@link isUrl}
45
69
  * @property {function} isNodeList - {@link isNodeList}
46
70
  * @property {function} isHTMLCollection - {@link isHTMLCollection}
47
- * @property {function} isAMD - {@link isAMD}
48
- * @property {function} isFreeModule - {@link isFreeModule}
49
- * @property {function} getRoot - {@link getRoot}
71
+ * @property {function} isSymbol - {@link isSymbol}
72
+ * @property {function} isBigInt - {@link isBigInt}
73
+ * @property {function} isInteger - {@link isInteger}
74
+ * @property {function} isFinite - {@link isFinite}
75
+ * @property {function} isPositive - {@link isPositive}
76
+ * @property {function} isNegative - {@link isNegative}
77
+ * @property {function} isAlpha - {@link isAlpha}
78
+ * @property {function} isAlphanumeric - {@link isAlphanumeric}
79
+ * @property {function} isNumericString - {@link isNumericString}
80
+ * @property {function} isLowercase - {@link isLowercase}
81
+ * @property {function} isUppercase - {@link isUppercase}
82
+ * @property {function} isHexColor - {@link isHexColor}
83
+ * @property {function} isJSON - {@link isJSON}
84
+ * @property {function} isUUID - {@link isUUID}
85
+ * @property {function} isIPv4 - {@link isIPv4}
86
+ * @property {function} isIterable - {@link isIterable}
87
+ * @property {function} isTruthy - {@link isTruthy}
88
+ * @property {function} isFalsy - {@link isFalsy}
89
+ * @property {function} isCallable - {@link isCallable}
90
+ * @property {function} isAsyncFunction - {@link isAsyncFunction}
91
+ * @property {function} isPromiseLike - {@link isPromiseLike}
92
+ * @property {function} isFrozen - {@link isFrozen}
93
+ * @property {function} isSealed - {@link isSealed}
50
94
  */
51
95
  const is = {
52
96
  'isArray':base(isArray),
@@ -61,13 +105,37 @@ import base from "./helper/base.js"
61
105
  'isObject':base(isObject),
62
106
  'isString':base(isString),
63
107
  'isUndefined':base(isUndefined),
108
+ 'isNil':base(isNil),
64
109
  'isEmail':base(isEmail),
65
110
  'isNaN':base(isNaN),
66
111
  'isRegExp':base(isRegExp),
67
112
  'isUrl':base(isUrl),
68
113
  'isNodeList':base(isNodeList),
69
114
  'isHTMLCollection':base(isHTMLCollection),
70
- 'isPromise':base(isPromise)
115
+ 'isPromise':base(isPromise),
116
+ 'isSymbol':base(isSymbol),
117
+ 'isBigInt':base(isBigInt),
118
+ 'isInteger':base(isInteger),
119
+ 'isFinite':base(isFinite),
120
+ 'isPositive':base(isPositive),
121
+ 'isNegative':base(isNegative),
122
+ 'isAlpha':base(isAlpha),
123
+ 'isAlphanumeric':base(isAlphanumeric),
124
+ 'isNumericString':base(isNumericString),
125
+ 'isLowercase':base(isLowercase),
126
+ 'isUppercase':base(isUppercase),
127
+ 'isHexColor':base(isHexColor),
128
+ 'isJSON':base(isJSON),
129
+ 'isUUID':base(isUUID),
130
+ 'isIPv4':base(isIPv4),
131
+ 'isIterable':base(isIterable),
132
+ 'isTruthy':base(isTruthy),
133
+ 'isFalsy':base(isFalsy),
134
+ 'isCallable':base(isCallable),
135
+ 'isAsyncFunction':base(isAsyncFunction),
136
+ 'isPromiseLike':base(isPromiseLike),
137
+ 'isFrozen':base(isFrozen),
138
+ 'isSealed':base(isSealed)
71
139
  }
72
140
 
73
- export { is as default }
141
+ export { is as default }
package/dist/pp-is.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ppIs=t()}(this,(function(){"use strict";const e=(e,t)=>(e=>Object.prototype.toString.call(e))(e)==="[object "+t+"]",t=t=>e(t,"String"),i=t=>e(t,"Array"),o=t=>e(t,"Object"),n=t=>!0===t||!1===t||e(t,"Boolean"),s=t=>e(t,"Function"),d=e=>Number.isNaN(Number.parseInt(e)),r=(e,t,i)=>{const o=e(t);return n(o)?o:i},l=e=>(t,i,o)=>((e,t,i,o)=>{const n=e(t);return n?!s(i)||r(i,t,n):!!s(o)&&r(o,t,n)})(e,t,i,o);return{isArray:l(i),isBoolean:l(n),isDate:l((t=>e(t,"Date"))),isElement:l((e=>!(!e||1!==e.nodeType))),isEmpty:l((e=>t(e)?""===e:i(e)?0==e.length:!o(e)||0===Object.keys(e).length)),isBlank:l((e=>!!t(e)&&(""===e||""===e.trim()))),isFunction:l(s),isNull:l((t=>e(t,"Null"))),isNumber:l((t=>e(t,"Number")&&!d(t))),isObject:l(o),isString:l(t),isUndefined:l((t=>e(t,"Undefined"))),isEmail:l((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:l(d),isRegExp:l((t=>e(t,"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))),isPromise:l((t=>e(t,"Promise")))}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ppIs=t()}(this,function(){"use strict";const e=(e,t)=>(e=>Object.prototype.toString.call(e))(e)==="[object "+t+"]",t=t=>e(t,"String"),i=t=>e(t,"Array"),s=t=>e(t,"Object"),n=t=>!0===t||!1===t||e(t,"Boolean"),o=t=>e(t,"Function"),r=t=>e(t,"Undefined"),a=t=>e(t,"Null"),l=e=>Number.isNaN(Number.parseInt(e)),u=t=>e(t,"Number")&&!l(t),f=(e,t,i)=>{const s=e(t);return n(s)?s:i},p=e=>(t,i,s)=>((e,t,i,s)=>{const n=e(t);return n?!o(i)||f(i,t,n):!!o(s)&&f(s,t,n)})(e,t,i,s);return{isArray:p(i),isBoolean:p(n),isDate:p(t=>e(t,"Date")),isElement:p(e=>!(!e||1!==e.nodeType)),isEmpty:p(e=>t(e)?""===e:i(e)?0==e.length:!s(e)||0===Object.keys(e).length),isBlank:p(e=>!!t(e)&&(""===e||""===e.trim())),isFunction:p(o),isNull:p(a),isNumber:p(u),isObject:p(s),isString:p(t),isUndefined:p(r),isNil:p(e=>r(e)||a(e)),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(l),isRegExp:p(t=>e(t,"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)),isPromise:p(t=>e(t,"Promise")),isSymbol:p(e=>"symbol"==typeof e),isBigInt:p(e=>"bigint"==typeof e),isInteger:p(e=>u(e)&&Number.isInteger(e)),isFinite:p(e=>u(e)&&Number.isFinite(e)),isPositive:p(e=>u(e)&&e>0),isNegative:p(e=>u(e)&&e<0),isAlpha:p(e=>!!t(e)&&/^[a-zA-Z]+$/.test(e)),isAlphanumeric:p(e=>!!t(e)&&/^[a-zA-Z0-9]+$/.test(e)),isNumericString:p(e=>!!t(e)&&/^[0-9]+$/.test(e)),isLowercase:p(e=>!!t(e)&&(e===e.toLowerCase()&&e!==e.toUpperCase())),isUppercase:p(e=>!!t(e)&&(e===e.toUpperCase()&&e!==e.toLowerCase())),isHexColor:p(e=>!!t(e)&&/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e)),isJSON:p(e=>{if(!t(e))return!1;try{return JSON.parse(e),!0}catch(e){return!1}}),isUUID:p(e=>!!t(e)&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)),isIPv4:p(e=>{if(!t(e))return!1;const i=e.split(".");return 4===i.length&&i.every(e=>{if(!/^[0-9]+$/.test(e))return!1;const t=Number(e);return t>=0&&t<=255&&String(t)===e})}),isIterable:p(e=>null!=e&&"function"==typeof e[Symbol.iterator]),isTruthy:p(e=>!0==!!e),isFalsy:p(e=>!e),isCallable:p(e=>"function"==typeof e),isAsyncFunction:p(t=>e(t,"AsyncFunction")),isPromiseLike:p(e=>null!=e&&"function"==typeof e.then),isFrozen:p(e=>s(e)&&Object.isFrozen(e)),isSealed:p(e=>s(e)&&Object.isSealed(e))}});
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.2.6",
4
+ "version": "1.3.0",
5
5
  "main": "dist/pp-is.min.js",
6
6
  "scripts": {
7
7
  "build": "rollup -c && terser -o ./dist/pp-is.min.js --compress --mangle --comments false -- ./dist/pp-is.rollup.js && rm -rf ./dist/pp-is.rollup.js",
@@ -33,12 +33,40 @@
33
33
  "isHTMLCollection",
34
34
  "isNodeList",
35
35
  "isBlank",
36
- "isPromise"
36
+ "isPromise",
37
+ "isNil",
38
+ "isSymbol",
39
+ "isBigInt",
40
+ "isInteger",
41
+ "isFinite",
42
+ "isPositive",
43
+ "isNegative",
44
+ "isAlpha",
45
+ "isAlphanumeric",
46
+ "isNumericString",
47
+ "isLowercase",
48
+ "isUppercase",
49
+ "isHexColor",
50
+ "isJSON",
51
+ "isUUID",
52
+ "isIPv4",
53
+ "isIterable",
54
+ "isTruthy",
55
+ "isFalsy",
56
+ "isCallable",
57
+ "isAsyncFunction",
58
+ "isPromiseLike",
59
+ "isFrozen",
60
+ "isSealed"
37
61
  ],
38
62
  "author": "Carlos Illesca",
39
63
  "license": "MIT",
40
64
  "bugs": {
41
65
  "url": "https://github.com/carlos-sweb/pp-is/issues"
42
66
  },
43
- "homepage": "https://github.com/carlos-sweb/pp-is#readme"
67
+ "homepage": "https://github.com/carlos-sweb/pp-is#readme",
68
+ "devDependencies": {
69
+ "rollup": "^4.62.2",
70
+ "terser": "^5.49.0"
71
+ }
44
72
  }