enterprise-number-classification-sdk 1.0.0-enterprise.stable

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 ADDED
@@ -0,0 +1,1828 @@
1
+ # Enterprise Number Classification SDK
2
+
3
+ [![License: @EGPSL10X-1.0](https://img.shields.io/badge/License-@EGPSL10X--1.0-blue.svg)](LICENSE)
4
+ [![NPM Version](https://img.shields.io/badge/npm-v10.x.x-red.svg)](https://npmjs.com/~tj-commits)
5
+ [![Engineering Quality](https://img.shields.io/badge/Code%20Quality-10x%20Engineered%20Enterprise%20Grade-gold.svg)](#quality-assurance-and-compliance)
6
+ [![Test Status](https://img.shields.io/badge/Tests-Passing-brightgreen.svg)](#)
7
+ [![Functional Purity](https://img.shields.io/badge/Paradigm-Functional%20First-blueviolet.svg)](#architectural-paradigms)
8
+ [![Security Hardened](https://img.shields.io/badge/Security-Prototype%20Pollution%20Protected-success.svg)](#security-architecture)
9
+
10
+ ---
11
+
12
+ ## 📋 Table of Contents
13
+
14
+ 1. [Executive Summary](#-executive-summary)
15
+ 2. [Installation](#-installation)
16
+ 3. [Quick Start Guide](#-quick-start-guide)
17
+ 4. [Core API Reference](#-core-api-reference)
18
+ 5. [Configuration System](#-configuration-system)
19
+ 6. [Comprehensive Examples](#-comprehensive-examples)
20
+ 7. [Architectural Deep Dive](#-architectural-deep-dive)
21
+ 8. [Security Architecture](#-security-architecture)
22
+ 9. [Performance Characteristics](#-performance-characteristics)
23
+ 10. [Error Handling](#-error-handling)
24
+ 11. [Testing Strategy](#-testing-strategy)
25
+ 12. [TypeScript Support](#-typescript-support)
26
+ 13. [Dependencies](#-dependencies)
27
+ 14. [Migration Guide](#-migration-guide)
28
+ 15. [Troubleshooting](#-troubleshooting)
29
+ 16. [Contributing](#-contributing)
30
+ 17. [Sponsors & Support](#-sponsors--support)
31
+ 18. [License](#-license)
32
+ 19. [Appendix](#-appendix)
33
+
34
+ ---
35
+
36
+ ## 🏛 Executive Summary
37
+
38
+ The **Enterprise Number Classification SDK** is a revolutionary, production-hardened numeric analysis suite developed by **10x'ly Made Software Ventures AB**. In an era where computational integrity cannot be taken for granted, this SDK provides a philosophically-sound, architecturally-pure solution to the fundamental problem of numeric parity classification.
39
+
40
+ ### The Problem Space
41
+
42
+ Traditional approaches to even/odd detection rely on the primitive modulus operator (`n % 2`), which suffers from several critical deficiencies:
43
+
44
+ - **Lack of Stack Visibility**: No granular execution tracing for debugging
45
+ - **Prototype Pollution Vulnerability**: Direct access to built-in methods
46
+ - **Insufficient Validation**: No multi-stage input verification
47
+ - **Missing Fallback Paths**: Single point of failure in recursion depth
48
+ - **Non-Enterprise Configuration**: No configurable validation firewall
49
+
50
+ ### Our Solution
51
+
52
+ This SDK addresses these concerns through:
53
+
54
+ 1. **Mutual Recursion Architecture**: Mathematical purity through recursive decomposition
55
+ 2. **Dual-Path Execution Strategy**: Primary recursive path with string-parsing fallback
56
+ 3. **Validation Firewall**: Multi-stage input verification system
57
+ 4. **Intrinsic Caching**: Prototype pollution protection via `get-intrinsic`
58
+ 5. **Enterprise Configuration**: Comprehensive option system for all validation gates
59
+ 6. **Quantum-Circuit-Simulation-Powered Boolean Logic**: Using `true-value` and `false-value` packages
60
+
61
+ ### Key Features
62
+
63
+ - ✅ **Mathematically Pure**: Recursive parity decomposition
64
+ - ✅ **Fail-Safe**: Automatic fallback to string-parsing on stack overflow
65
+ - ✅ **Security Hardened**: Protected against prototype pollution attacks
66
+ - ✅ **Extensively Validated**: Multi-gate input validation firewall
67
+ - ✅ **Fully Configurable**: Enterprise-grade option system
68
+ - ✅ **Debug-Ready**: Chromatic telemetry with `chalkbox`
69
+ - ✅ **TypeScript Native**: Complete type definitions included
70
+ - ✅ **Zero Trust**: Uses `get-intrinsic` for all JavaScript primitives
71
+ - ✅ **Functional First**: Immutable, pure functional design patterns
72
+
73
+ ---
74
+
75
+ ## 🚀 Installation
76
+
77
+ Deploy the SDK into your enterprise environment via your preferred Node Package Manager.
78
+
79
+ ### NPM (Recommended)
80
+ ```bash
81
+ npm install enterprise-number-classification-sdk
82
+ ```
83
+
84
+ ### Yarn
85
+ ```bash
86
+ yarn add enterprise-number-classification-sdk
87
+ ```
88
+
89
+ ### PNPM
90
+ ```bash
91
+ pnpm add enterprise-number-classification-sdk
92
+ ```
93
+
94
+ > ⚠️ **Note**: Use of PNPM is philosophically discouraged by the 10x Engineering Board due to its non-standard resolution algorithms.
95
+
96
+ ### Verification
97
+
98
+ After installation, verify the SDK is correctly installed:
99
+
100
+ ```bash
101
+ npm list enterprise-number-classification-sdk
102
+ ```
103
+
104
+ You should see the package listed in your dependency tree.
105
+
106
+ ---
107
+
108
+ ## 🎯 Quick Start Guide
109
+
110
+ ### Basic Usage
111
+
112
+ ```javascript
113
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
114
+
115
+ // Simple parity checks
116
+ console.log(checkEven(8)) // true
117
+ console.log(checkEven(9)) // false
118
+ console.log(checkOdd(7)) // true
119
+ console.log(checkOdd(10)) // false
120
+ ```
121
+
122
+ ### With Validation Options
123
+
124
+ ```javascript
125
+ const options = {
126
+ throwOnNonInteger: true,
127
+ enableDebug: true
128
+ }
129
+
130
+ try {
131
+ const result = checkEven(42, options)
132
+ console.log(`42 is even: ${result}`)
133
+ } catch (error) {
134
+ console.error('Validation failed:', error.message)
135
+ }
136
+ ```
137
+
138
+ ### With String Input
139
+
140
+ ```javascript
141
+ const options = {
142
+ allowNumberStrings: true
143
+ }
144
+
145
+ const result = checkOdd("1337", options)
146
+ console.log(`1337 is odd: ${result}`) // true
147
+ ```
148
+
149
+ ---
150
+
151
+ ## 📖 Core API Reference
152
+
153
+ ### `checkEven(number, options?)`
154
+
155
+ Analyzes a numeric node to determine its evenness state through a dual-path execution strategy.
156
+
157
+ #### Parameters
158
+
159
+ | Parameter | Type | Required | Description |
160
+ |-----------|------|----------|-------------|
161
+ | `number` | `number \| string \| any` | Yes | The numeric entity to classify |
162
+ | `options` | `ClassificationOptions` | No | Configuration manifest for validation behavior |
163
+
164
+ #### Returns
165
+
166
+ - **Type**: `boolean`
167
+ - **Value**: `true` if the number is even, `false` otherwise or if validation fails
168
+
169
+ #### Execution Paths
170
+
171
+ 1. **Primary Path**: Mutual recursion through absolute magnitude
172
+ - Uses `checkEvenInternal()` which recursively decrements to base cases (0 or 1)
173
+ - For even number `n`: checks if `n-1` is odd
174
+ - Base case: `0` returns `true`, `1` returns `false`
175
+
176
+ 2. **Rescue Path**: String-vectorized digit analysis
177
+ - Activated on `RangeError: Maximum call stack size exceeded`
178
+ - Uses `checkEvenAlternative()` which examines the last digit
179
+ - Digits 0, 2, 4, 6, 8 → `true`
180
+ - Digits 1, 3, 5, 7, 9 → `false`
181
+
182
+ #### Examples
183
+
184
+ ```javascript
185
+ // Standard integers
186
+ checkEven(0) // true (zero is even)
187
+ checkEven(1) // false
188
+ checkEven(42) // true
189
+ checkEven(-8) // true (negative numbers supported)
190
+
191
+ // With validation
192
+ checkEven(3.14, { throwOnNonInteger: true }) // throws TypeError
193
+
194
+ // With string input
195
+ checkEven("100", { allowNumberStrings: true }) // true
196
+
197
+ // With debug logging
198
+ checkEven(7, { enableDebug: true })
199
+ // Output:
200
+ // === [DEBUG] Validating Input: 7 ===
201
+ // false
202
+ ```
203
+
204
+ ---
205
+
206
+ ### `checkOdd(number, options?)`
207
+
208
+ Identifies if a numeric entity resides within the odd parity spectrum.
209
+
210
+ #### Parameters
211
+
212
+ | Parameter | Type | Required | Description |
213
+ |-----------|------|----------|-------------|
214
+ | `number` | `number \| string \| any` | Yes | The numeric entity to classify |
215
+ | `options` | `ClassificationOptions` | No | Configuration manifest for validation behavior |
216
+
217
+ #### Returns
218
+
219
+ - **Type**: `boolean`
220
+ - **Value**: `true` if the number is odd, `false` otherwise or if validation fails
221
+
222
+ #### Execution Paths
223
+
224
+ 1. **Primary Path**: Mutual recursion through absolute magnitude
225
+ - Uses `checkOddInternal()` which recursively decrements to base cases
226
+ - For odd number `n`: checks if `n-1` is even
227
+ - Base case: `0` returns `false`, `1` returns `true`
228
+
229
+ 2. **Rescue Path**: String-vectorized digit analysis
230
+ - Activated on stack overflow
231
+ - Uses `checkOddAlternative()` which examines the last digit
232
+ - Digits 1, 3, 5, 7, 9 → `true`
233
+ - Digits 0, 2, 4, 6, 8 → `false`
234
+
235
+ #### Examples
236
+
237
+ ```javascript
238
+ // Standard integers
239
+ checkOdd(0) // false
240
+ checkOdd(1) // true
241
+ checkOdd(43) // true
242
+ checkOdd(-7) // true (negative numbers supported)
243
+
244
+ // Edge cases
245
+ checkOdd(NaN) // false (without throw option)
246
+ checkOdd(Infinity) // false (without throw option)
247
+
248
+ // With validation firewall
249
+ checkOdd(NaN, { throwOnNaN: true }) // throws RangeError
250
+ ```
251
+
252
+ ---
253
+
254
+ ## ⚙️ Configuration System
255
+
256
+ ### ClassificationOptions Interface
257
+
258
+ The SDK provides extensive configuration through the `ClassificationOptions` object. All properties are optional and default to the most secure, conservative state.
259
+
260
+ #### Complete Option Reference
261
+
262
+ | Option | Type | Default | Description | Use Case |
263
+ |--------|------|---------|-------------|----------|
264
+ | `throwOnNonNumber` | `boolean` | `false` | Throws `TypeError` if input is not a number | Strict type enforcement in critical paths |
265
+ | `throwOnNonInteger` | `boolean` | `false` | Throws `TypeError` if input contains decimals | Financial calculations requiring integer values |
266
+ | `throwOnNonFinite` | `boolean` | `false` | Throws `RangeError` if input is `Infinity` or `-Infinity` | Boundary-safe mathematical operations |
267
+ | `throwOnNaN` | `boolean` | `false` | Throws `RangeError` if input is `NaN` | Preventing silent NaN propagation |
268
+ | `allowNumberStrings` | `boolean` | `false` | Permits string inputs like `"42"` via intrinsic casting | API endpoints accepting string data |
269
+ | `enableDebug` | `boolean` | `false` | Emits chromatic telemetry to console | Development and troubleshooting |
270
+
271
+ ### Option Combinations
272
+
273
+ #### Maximum Security Mode
274
+ ```javascript
275
+ const STRICT_OPTIONS = {
276
+ throwOnNonNumber: true,
277
+ throwOnNonInteger: true,
278
+ throwOnNonFinite: true,
279
+ throwOnNaN: true,
280
+ allowNumberStrings: false,
281
+ enableDebug: false
282
+ }
283
+
284
+ checkEven(value, STRICT_OPTIONS) // Will throw on any invalid input
285
+ ```
286
+
287
+ #### Permissive API Mode
288
+ ```javascript
289
+ const API_OPTIONS = {
290
+ throwOnNonNumber: false,
291
+ throwOnNonInteger: false,
292
+ throwOnNonFinite: false,
293
+ throwOnNaN: false,
294
+ allowNumberStrings: true,
295
+ enableDebug: false
296
+ }
297
+
298
+ checkEven(userInput, API_OPTIONS) // Returns false for invalid input
299
+ ```
300
+
301
+ #### Development Mode
302
+ ```javascript
303
+ const DEV_OPTIONS = {
304
+ throwOnNonNumber: true,
305
+ throwOnNonInteger: true,
306
+ throwOnNonFinite: true,
307
+ throwOnNaN: true,
308
+ allowNumberStrings: false,
309
+ enableDebug: true
310
+ }
311
+
312
+ checkEven(value, DEV_OPTIONS) // Full validation with debug output
313
+ ```
314
+
315
+ ---
316
+
317
+ ## 📚 Comprehensive Examples
318
+
319
+ ### Example 1: Basic Parity Verification
320
+
321
+ ```javascript
322
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
323
+
324
+ // Testing even numbers
325
+ console.log(checkEven(0)) // true
326
+ console.log(checkEven(2)) // true
327
+ console.log(checkEven(100)) // true
328
+ console.log(checkEven(-42)) // true
329
+
330
+ // Testing odd numbers
331
+ console.log(checkOdd(1)) // true
332
+ console.log(checkOdd(7)) // true
333
+ console.log(checkOdd(999)) // true
334
+ console.log(checkOdd(-13)) // true
335
+
336
+ // Mixed testing
337
+ const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
338
+ numbers.forEach(n => {
339
+ console.log(`${n} is ${checkEven(n) ? 'even' : 'odd'}`)
340
+ })
341
+ ```
342
+
343
+ ### Example 2: High-Integrity Validation Pipeline
344
+
345
+ ```javascript
346
+ const { checkEven } = require('enterprise-number-classification-sdk')
347
+
348
+ function validateAndClassify(input) {
349
+ const options = {
350
+ throwOnNonInteger: true,
351
+ throwOnNaN: true,
352
+ throwOnNonFinite: true,
353
+ enableDebug: true
354
+ }
355
+
356
+ try {
357
+ const result = checkEven(input, options)
358
+ return {
359
+ success: true,
360
+ value: input,
361
+ isEven: result,
362
+ isOdd: !result
363
+ }
364
+ } catch (error) {
365
+ return {
366
+ success: false,
367
+ value: input,
368
+ error: error.message,
369
+ errorType: error.name
370
+ }
371
+ }
372
+ }
373
+
374
+ // Test cases
375
+ console.log(validateAndClassify(42)) // Success: even
376
+ console.log(validateAndClassify(43)) // Success: odd
377
+ console.log(validateAndClassify(3.14)) // Error: not an integer
378
+ console.log(validateAndClassify(NaN)) // Error: NaN detected
379
+ console.log(validateAndClassify(Infinity)) // Error: not finite
380
+ ```
381
+
382
+ ### Example 3: String Input Processing
383
+
384
+ ```javascript
385
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
386
+
387
+ const options = {
388
+ allowNumberStrings: true,
389
+ throwOnNonInteger: true
390
+ }
391
+
392
+ // Processing user input from forms/APIs
393
+ const userInputs = ["42", "1337", "999", "0", "-8"]
394
+
395
+ userInputs.forEach(input => {
396
+ try {
397
+ const isEven = checkEven(input, options)
398
+ console.log(`"${input}" is ${isEven ? 'even' : 'odd'}`)
399
+ } catch (error) {
400
+ console.error(`Invalid input "${input}": ${error.message}`)
401
+ }
402
+ })
403
+
404
+ // Output:
405
+ // "42" is even
406
+ // "1337" is odd
407
+ // "999" is odd
408
+ // "0" is even
409
+ // "-8" is even
410
+ ```
411
+
412
+ ### Example 4: Batch Processing with Error Handling
413
+
414
+ ```javascript
415
+ const { checkEven } = require('enterprise-number-classification-sdk')
416
+
417
+ function batchClassify(numbers, strictMode = false) {
418
+ const options = strictMode ? {
419
+ throwOnNonInteger: true,
420
+ throwOnNaN: true,
421
+ throwOnNonFinite: true
422
+ } : {}
423
+
424
+ const results = {
425
+ even: [],
426
+ odd: [],
427
+ invalid: []
428
+ }
429
+
430
+ numbers.forEach(num => {
431
+ try {
432
+ if (checkEven(num, options)) {
433
+ results.even.push(num)
434
+ } else {
435
+ results.odd.push(num)
436
+ }
437
+ } catch (error) {
438
+ results.invalid.push({ value: num, error: error.message })
439
+ }
440
+ })
441
+
442
+ return results
443
+ }
444
+
445
+ // Test with mixed input
446
+ const mixedData = [1, 2, 3, 4, 5, 3.14, NaN, Infinity, -7, 0]
447
+ const results = batchClassify(mixedData, true)
448
+
449
+ console.log('Even numbers:', results.even)
450
+ // [2, 4, 0]
451
+
452
+ console.log('Odd numbers:', results.odd)
453
+ // [1, 3, 5, -7]
454
+
455
+ console.log('Invalid inputs:', results.invalid)
456
+ // [
457
+ // { value: 3.14, error: '...' },
458
+ // { value: NaN, error: '...' },
459
+ // { value: Infinity, error: '...' }
460
+ // ]
461
+ ```
462
+
463
+ ### Example 5: Integration with Express API
464
+
465
+ ```javascript
466
+ const express = require('express')
467
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
468
+
469
+ const app = express()
470
+ app.use(express.json())
471
+
472
+ // API endpoint for parity checking
473
+ app.post('/api/classify', (req, res) => {
474
+ const { number, type = 'even', strict = false } = req.body
475
+
476
+ const options = {
477
+ allowNumberStrings: true,
478
+ throwOnNonInteger: strict,
479
+ throwOnNaN: strict,
480
+ throwOnNonFinite: strict
481
+ }
482
+
483
+ try {
484
+ const checkFunc = type === 'even' ? checkEven : checkOdd
485
+ const result = checkFunc(number, options)
486
+
487
+ res.json({
488
+ success: true,
489
+ input: number,
490
+ type,
491
+ result,
492
+ message: `${number} is ${result ? type : 'not ' + type}`
493
+ })
494
+ } catch (error) {
495
+ res.status(400).json({
496
+ success: false,
497
+ input: number,
498
+ error: error.message,
499
+ errorType: error.name
500
+ })
501
+ }
502
+ })
503
+
504
+ app.listen(3000, () => {
505
+ console.log('Classification API running on port 3000')
506
+ })
507
+ ```
508
+
509
+ ### Example 6: Functional Programming Pattern
510
+
511
+ ```javascript
512
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
513
+
514
+ // Higher-order function for filtering
515
+ const createParityFilter = (isEven) => (numbers, options) => {
516
+ const checkFunc = isEven ? checkEven : checkOdd
517
+ return numbers.filter(n => {
518
+ try {
519
+ return checkFunc(n, options)
520
+ } catch {
521
+ return false
522
+ }
523
+ })
524
+ }
525
+
526
+ const filterEven = createParityFilter(true)
527
+ const filterOdd = createParityFilter(false)
528
+
529
+ // Usage
530
+ const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
531
+ const evenNumbers = filterEven(numbers)
532
+ const oddNumbers = filterOdd(numbers)
533
+
534
+ console.log('Even:', evenNumbers) // [2, 4, 6, 8, 10]
535
+ console.log('Odd:', oddNumbers) // [1, 3, 5, 7, 9]
536
+
537
+ // Compose with other operations
538
+ const sumEvenNumbers = numbers
539
+ .filter(n => checkEven(n))
540
+ .reduce((sum, n) => sum + n, 0)
541
+
542
+ console.log('Sum of even numbers:', sumEvenNumbers) // 30
543
+ ```
544
+
545
+ ### Example 7: Large Number Processing
546
+
547
+ ```javascript
548
+ const { checkEven } = require('enterprise-number-classification-sdk')
549
+
550
+ // The SDK automatically uses string-parsing fallback for very large numbers
551
+ // that would cause stack overflow in recursive path
552
+
553
+ const veryLargeNumber = 999999999999999
554
+
555
+ // This will trigger the rescue path and use string-parsing
556
+ const result = checkEven(veryLargeNumber)
557
+ console.log(`${veryLargeNumber} is ${result ? 'even' : 'odd'}`)
558
+ // "999999999999999 is odd"
559
+
560
+ // Testing boundary numbers
561
+ console.log(`MAX_SAFE_INTEGER is ${checkEven(Number.MAX_SAFE_INTEGER) ? 'even' : 'odd'}`)
562
+ // "MAX_SAFE_INTEGER is odd"
563
+
564
+ console.log(`MIN_SAFE_INTEGER is ${checkEven(Number.MIN_SAFE_INTEGER) ? 'even' : 'odd'}`)
565
+ // "MIN_SAFE_INTEGER is odd"
566
+ ```
567
+
568
+ ---
569
+
570
+ ## 🏗 Architectural Deep Dive
571
+
572
+ ### Mutual Recursion Strategy
573
+
574
+ The core of the SDK's mathematical purity lies in its mutual recursion implementation:
575
+
576
+ ```
577
+ Even(n) ⟺ Odd(n-1)
578
+ Odd(n) ⟺ Even(n-1)
579
+
580
+ Base cases:
581
+ Even(0) = true
582
+ Odd(0) = false
583
+ Even(1) = false
584
+ Odd(1) = true
585
+ ```
586
+
587
+ #### Why Mutual Recursion?
588
+
589
+ 1. **Mathematical Elegance**: Directly mirrors the mathematical definition of parity
590
+ 2. **Stack Traceability**: Every decrement is visible in the call stack for debugging
591
+ 3. **Functional Purity**: No mutable state, no side effects
592
+ 4. **Conceptual Clarity**: The algorithm is self-documenting
593
+
594
+ #### Example Trace for `checkEven(4)`
595
+
596
+ ```
597
+ checkEven(4)
598
+ → checkOddInternal(3)
599
+ → checkEvenInternal(2)
600
+ → checkOddInternal(1)
601
+ → return true (base case)
602
+ → return true
603
+ → return true
604
+ → return true
605
+ ```
606
+
607
+ ### Dual-Path Execution Architecture
608
+
609
+ ```
610
+ ┌─────────────────┐
611
+ │ User Input │
612
+ └────────┬────────┘
613
+
614
+
615
+ ┌─────────────────┐
616
+ │ Validation │
617
+ │ Firewall │
618
+ └────────┬────────┘
619
+
620
+
621
+ ┌─────────────────┐
622
+ │ Primary Path: │
623
+ │ Recursive │
624
+ │ Logic │
625
+ └────────┬────────┘
626
+
627
+ ├─── Success ──→ Result
628
+
629
+ └─── RangeError (Stack Overflow)
630
+
631
+
632
+ ┌─────────────────┐
633
+ │ Rescue Path: │
634
+ │ String-Parsing │
635
+ │ Algorithm │
636
+ └────────┬────────┘
637
+
638
+ └──→ Result
639
+ ```
640
+
641
+ ### Validation Firewall Stages
642
+
643
+ The SDK implements a five-stage validation process:
644
+
645
+ #### Stage 1: Type Validation
646
+ ```javascript
647
+ isNumber(number, {
648
+ allowInfinite: true,
649
+ allowNumberStrings: options.allowNumberStrings
650
+ })
651
+ ```
652
+ - Validates basic numeric type
653
+ - Can optionally accept string representations
654
+
655
+ #### Stage 2: NaN Detection
656
+ ```javascript
657
+ if (isNaN(number)) {
658
+ // Handle or throw based on options.throwOnNaN
659
+ }
660
+ ```
661
+ - Uses rigorous `@is-(unknown)/is-nan` package
662
+ - Catches `NaN` before it propagates
663
+
664
+ #### Stage 3: Finite Validation
665
+ ```javascript
666
+ if (not(isFinite)(number)) {
667
+ // Handle or throw based on options.throwOnNonFinite
668
+ }
669
+ ```
670
+ - Prevents `Infinity` and `-Infinity` processing
671
+ - Uses `@stdlib/assert-is-finite`
672
+
673
+ #### Stage 4: Integer Validation
674
+ ```javascript
675
+ if (isNotInteger(number)) {
676
+ // Handle or throw based on options.throwOnNonInteger
677
+ }
678
+ ```
679
+ - Hybrid check using two separate integer validators
680
+ - Handles edge cases like `-0`
681
+
682
+ #### Stage 5: Parity Validation
683
+ ```javascript
684
+ if (!numberOddOrEven(number, false)) {
685
+ return falseValue()
686
+ }
687
+ ```
688
+ - Ensures the number has a defined parity
689
+ - Final gate before algorithm execution
690
+
691
+ ---
692
+
693
+ ## 🔒 Security Architecture
694
+
695
+ ### Prototype Pollution Protection
696
+
697
+ The SDK uses `get-intrinsic` to cache raw JavaScript intrinsics, preventing prototype pollution attacks:
698
+
699
+ ```javascript
700
+ const $Number = getIntrinsic("%Number%")
701
+ const $String = getIntrinsic("%String%")
702
+ const $abs = getIntrinsic("%Math.abs%")
703
+ const $parseInt = getIntrinsic("%parseInt%")
704
+ ```
705
+
706
+ #### Why This Matters
707
+
708
+ Consider this attack vector:
709
+ ```javascript
710
+ // Malicious code
711
+ Number.prototype.valueOf = function() { return 42 }
712
+
713
+ // Without protection
714
+ const x = 13
715
+ console.log(x % 2) // Could be compromised
716
+
717
+ // With intrinsic caching
718
+ const x = 13
719
+ console.log($abs(x)) // Always safe
720
+ ```
721
+
722
+ ### Immutable Operation Chains
723
+
724
+ All operations use functional, immutable patterns:
725
+
726
+ ```javascript
727
+ // ❌ Mutable approach (vulnerable)
728
+ let result = number
729
+ result = result - 1
730
+ return checkEven(result)
731
+
732
+ // ✅ Immutable approach (used by SDK)
733
+ return checkEven(subtract(number, number1))
734
+ ```
735
+
736
+ ### Function Isolation
737
+
738
+ The entire SDK is wrapped in an IIFE to prevent scope pollution:
739
+
740
+ ```javascript
741
+ ;((factory) => {
742
+ module.exports = factory()
743
+ })(function factory() {
744
+ // All implementation code here
745
+ return { checkEven, checkOdd }
746
+ })
747
+ ```
748
+
749
+ ---
750
+
751
+ ## 🚨 Error Handling
752
+
753
+ ### Error Types
754
+
755
+ The SDK throws two types of errors via the `immediate-error` package:
756
+
757
+ #### TypeError
758
+ Thrown when type validation fails:
759
+ - Non-number input (when `throwOnNonNumber: true`)
760
+ - Non-integer input (when `throwOnNonInteger: true`)
761
+
762
+ ```javascript
763
+ try {
764
+ checkEven(3.14, { throwOnNonInteger: true })
765
+ } catch (error) {
766
+ console.log(error.name) // "TypeError"
767
+ console.log(error.message) // "[ENTERPRISE NUMBER CLASSIFICATION SDK]: ..."
768
+ }
769
+ ```
770
+
771
+ #### RangeError
772
+ Thrown when value is out of acceptable range:
773
+ - NaN input (when `throwOnNaN: true`)
774
+ - Infinite input (when `throwOnNonFinite: true`)
775
+
776
+ ```javascript
777
+ try {
778
+ checkEven(NaN, { throwOnNaN: true })
779
+ } catch (error) {
780
+ console.log(error.name) // "RangeError"
781
+ console.log(error.message) // "[ENTERPRISE NUMBER CLASSIFICATION SDK]: ..."
782
+ }
783
+ ```
784
+
785
+ ### Error Messages
786
+
787
+ All error messages follow the format:
788
+ ```
789
+ [ENTERPRISE NUMBER CLASSIFICATION SDK]: {description}, and option to throw when {condition} is enabled.
790
+ ```
791
+
792
+ Examples:
793
+ - `"Given parameter was not a number, and option to throw when given parameter is not a number is enabled."`
794
+ - `"Given parameter was NaN, and option to throw when given parameter is NaN is enabled."`
795
+ - `"Given parameter was not finite, and option to throw when given parameter is not finite is enabled."`
796
+ - `"Given parameter was not an integer, and option to throw when given parameter is not an integer is enabled."`
797
+
798
+ ### Graceful Degradation
799
+
800
+ When throw options are disabled (default), the SDK returns `falseValue()` instead of throwing:
801
+
802
+ ```javascript
803
+ // No throw, graceful return
804
+ checkEven(NaN) // false (instead of throwing)
805
+ checkEven(Infinity) // false (instead of throwing)
806
+ checkEven("invalid") // false (instead of throwing)
807
+ checkEven(3.14) // false (instead of throwing)
808
+ ```
809
+
810
+ ---
811
+
812
+ ## 🧪 Testing Strategy
813
+
814
+ ### Test Framework
815
+
816
+ The SDK uses **Enterprise10xTestingFrameworkJS**, a proprietary testing framework designed for enterprise-grade validation.
817
+
818
+ ### Test Categories
819
+
820
+ #### 1. Functional Error Boundary Tests
821
+ ```javascript
822
+ enterpriseTest("Functional Error Boundary Audit", (assert) => {
823
+ // NaN validation
824
+ try {
825
+ sdk.checkEven(NaN, { throwOnNaN: trueValue() })
826
+ assert(falseValue(), "Should have thrown")
827
+ } catch (e) {
828
+ assert(e.name === "RangeError", "Correct error type")
829
+ }
830
+
831
+ // Non-integer validation
832
+ try {
833
+ sdk.checkOdd(3.14, { throwOnNonInteger: trueValue() })
834
+ assert(falseValue(), "Should have thrown")
835
+ } catch (e) {
836
+ assert(e.name === "TypeError", "Correct error type")
837
+ }
838
+ })
839
+ ```
840
+
841
+ #### 2. Configuration Utility Tests
842
+ ```javascript
843
+ enterpriseTest("Extended Configuration Utility Audit", (assert) => {
844
+ // String number support
845
+ const stringResult = sdk.checkEven("10", {
846
+ allowNumberStrings: trueValue()
847
+ })
848
+ assert(stringResult === trueValue(), "String '10' is even")
849
+
850
+ // Debug mode
851
+ const debugResult = sdk.checkOdd(1, {
852
+ enableDebug: trueValue()
853
+ })
854
+ assert(debugResult === trueValue(), "Debug mode works")
855
+
856
+ // Silent failure
857
+ const silentFail = sdk.checkEven("invalid", {
858
+ throwOnNonNumber: falseValue()
859
+ })
860
+ assert(silentFail === falseValue(), "Returns false on invalid")
861
+ })
862
+ ```
863
+
864
+ #### 3. Boundary Value Tests
865
+ - Negative zero (`-0`)
866
+ - Positive zero (`0`)
867
+ - Unity (`1`)
868
+ - `Number.MAX_SAFE_INTEGER`
869
+ - `Number.MIN_SAFE_INTEGER`
870
+ - `Infinity` and `-Infinity`
871
+ - `NaN`
872
+
873
+ #### 4. Parity Correctness Tests
874
+ - All digits 0-9
875
+ - Positive and negative numbers
876
+ - Large numbers requiring string-parsing fallback
877
+
878
+ ### Running Tests
879
+
880
+ ```bash
881
+ npm test
882
+ ```
883
+
884
+ ### Test Coverage
885
+
886
+ The SDK maintains 100% code coverage across all execution paths:
887
+ - ✅ All validation gates
888
+ - ✅ Both recursive and string-parsing paths
889
+ - ✅ All error conditions
890
+ - ✅ All configuration combinations
891
+ - ✅ All base cases and edge cases
892
+
893
+ ---
894
+
895
+ ## 📘 TypeScript Support
896
+
897
+ ### Type Definitions
898
+
899
+ The SDK includes comprehensive TypeScript definitions:
900
+
901
+ ```typescript
902
+ declare module "enterprise-number-classification-sdk" {
903
+ export interface ClassificationOptions {
904
+ throwOnNonNumber?: boolean
905
+ throwOnNonInteger?: boolean
906
+ throwOnNonFinite?: boolean
907
+ throwOnNaN?: boolean
908
+ allowNumberStrings?: boolean
909
+ enableDebug?: boolean
910
+ }
911
+
912
+ export function checkEven(
913
+ number: number | string | any,
914
+ options?: ClassificationOptions
915
+ ): boolean
916
+
917
+ export function checkOdd(
918
+ number: number | string | any,
919
+ options?: ClassificationOptions
920
+ ): boolean
921
+ }
922
+ ```
923
+
924
+ ### Usage in TypeScript
925
+
926
+ ```typescript
927
+ import { checkEven, checkOdd, ClassificationOptions } from 'enterprise-number-classification-sdk'
928
+
929
+ // Type-safe configuration
930
+ const options: ClassificationOptions = {
931
+ throwOnNonInteger: true,
932
+ throwOnNaN: true,
933
+ enableDebug: true
934
+ }
935
+
936
+ // Type-safe function calls
937
+ const result: boolean = checkEven(42, options)
938
+ const isOdd: boolean = checkOdd(13, options)
939
+
940
+ // Compile-time type checking
941
+ checkEven("42", { allowNumberStrings: true }) // ✅ Valid
942
+ // @ts-expect-error - invalid option
943
+ checkEven(42, { invalidOption: true }) // ❌ Compile error
944
+ ```
945
+
946
+ ### Generic Type Support
947
+
948
+ ```typescript
949
+ function classifyNumbers<T extends number | string>(
950
+ numbers: T[],
951
+ options?: ClassificationOptions
952
+ ): { even: T[], odd: T[] } {
953
+ const result = { even: [] as T[], odd: [] as T[] }
954
+
955
+ numbers.forEach(num => {
956
+ if (checkEven(num, options)) {
957
+ result.even.push(num)
958
+ } else {
959
+ result.odd.push(num)
960
+ }
961
+ })
962
+
963
+ return result
964
+ }
965
+
966
+ // Usage with type inference
967
+ const numbers = [1, 2, 3, 4, 5]
968
+ const classified = classifyNumbers(numbers)
969
+ // classified.even has type: number[]
970
+ // classified.odd has type: number[]
971
+ ```
972
+
973
+ ---
974
+
975
+ ## 📦 Dependencies
976
+
977
+ ### Core Dependencies
978
+
979
+ The SDK leverages 30+ specialized packages for maximum functional purity and enterprise reliability:
980
+
981
+ #### Type Validation & Intrinsics
982
+ - **get-intrinsic** (^1.2.0): Caches raw JavaScript intrinsics for prototype pollution protection
983
+ - **uncurried-intrinsics** (^1.0.0): Provides uncurried forms of cached methods
984
+ - **is-actual-number** (^1.0.0): Rigorous numeric type-checking engine
985
+ - **is-number-odd-or-even** (^1.0.0): Validates odd-or-even state
986
+ - **@is-(unknown)/is-nan** (^1.0.0): Robust NaN detection
987
+ - **@stdlib/assert-is-finite** (^1.0.0): Finite value validation
988
+ - **is-not-integer** (^1.0.0): Primary integer validation
989
+ - **util-x** (^1.0.0): Secondary integer validation utilities
990
+ - **is-x** (^1.0.0): Specialized checks including negative zero
991
+ - **is-eq-zero** (^1.0.0): Zero-value identification
992
+ - **is-eq-one** (^1.0.0): Unity-value identification
993
+
994
+ #### Functional Programming Primitives
995
+ - **@not-js/not** (^1.0.0): Creates negated versions of functions
996
+ - **literally** (^1.0.0): Constant function for identity operations
997
+ - **yanoop** (^1.0.0): Functional execution triggers (doop, noop)
998
+ - **true-value** (^1.0.0): Quantum-circuit-simulation-powered boolean true
999
+ - **false-value** (^1.0.0): Quantum-circuit-simulation-powered boolean false
1000
+ - **subtract** (^1.0.0): Functional subtraction module
1001
+ - **attempt-statement** (^1.0.0): Functional error handling patterns
1002
+ - **while2** (^1.0.0): Functional while-loop abstraction
1003
+ - **construct-new** (^1.0.0): Functional instantiation of constructors
1004
+ - **switcher-statement** (^1.0.0): Functional switch expressions
1005
+
1006
+ #### String & Array Operations
1007
+ - **string.prototype.split** (^1.0.0): Ponyfilled string splitting
1008
+ - **array.prototype.toreversed** (^1.0.0): Non-mutating array reversal
1009
+ - **@extra-array/length** (^1.0.0): Safe array length determination
1010
+ - **object.assign** (^4.1.0): Object.assign polyfill
1011
+ - **empty-string** (^1.0.0): Empty string constant
1012
+
1013
+ #### Numeric Constants
1014
+ - **@positive-numbers/zero** through **@positive-numbers/ten**: Individual packages for numbers 0-10
1015
+
1016
+ #### Error Handling & Logging
1017
+ - **immediate-error** (^1.0.0): Functional immediate error termination
1018
+ - **chalkbox** (^1.0.0): Chromatic console formatting
1019
+ - **logtoconsole** (^1.0.0): Enterprise-grade logging abstraction
1020
+
1021
+ #### Meta-Performance
1022
+ - **none** (^1.0.0): Meta-philosophical performance optimization layer
1023
+
1024
+ ### Dependency Philosophy
1025
+
1026
+ Each dependency serves a specific architectural purpose:
1027
+
1028
+ 1. **Isolation**: Each concern is isolated into its own package
1029
+ 2. **Immutability**: All operations are functional and immutable
1030
+ 3. **Security**: Intrinsic caching prevents prototype pollution
1031
+ 4. **Testability**: Small, focused packages are easier to test
1032
+ 5. **Maintainability**: Single Responsibility Principle at package level
1033
+
1034
+ ### Dependency Tree Size
1035
+
1036
+ ```bash
1037
+ $ npm ls --all | wc -l
1038
+ 156 # Total packages including transitive dependencies
1039
+ ```
1040
+
1041
+ ### Bundle Size
1042
+
1043
+ - **Minified**: ~45KB
1044
+ - **Minified + Gzipped**: ~12KB
1045
+ - **Total Install Size**: ~2.1MB (including all dependencies)
1046
+
1047
+ ---
1048
+
1049
+ ## 🔄 Migration Guide
1050
+
1051
+ ### From Native JavaScript
1052
+
1053
+ If you're currently using the primitive modulus operator, migration is straightforward:
1054
+
1055
+ #### Before
1056
+ ```javascript
1057
+ function isEven(n) {
1058
+ return n % 2 === 0
1059
+ }
1060
+
1061
+ function isOdd(n) {
1062
+ return n % 2 !== 0
1063
+ }
1064
+ ```
1065
+
1066
+ #### After
1067
+ ```javascript
1068
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
1069
+
1070
+ // Direct replacement
1071
+ const isEvenResult = checkEven(n)
1072
+ const isOddResult = checkOdd(n)
1073
+ ```
1074
+
1075
+ ### Adding Validation
1076
+
1077
+ #### Before (No Validation)
1078
+ ```javascript
1079
+ function isEven(n) {
1080
+ return n % 2 === 0 // No validation!
1081
+ }
1082
+
1083
+ isEven(3.14) // true (incorrect!)
1084
+ isEven(NaN) // false (silent failure)
1085
+ isEven(Infinity) // false (silent failure)
1086
+ ```
1087
+
1088
+ #### After (With Validation)
1089
+ ```javascript
1090
+ const options = {
1091
+ throwOnNonInteger: true,
1092
+ throwOnNaN: true,
1093
+ throwOnNonFinite: true
1094
+ }
1095
+
1096
+ try {
1097
+ checkEven(3.14, options) // throws TypeError
1098
+ checkEven(NaN, options) // throws RangeError
1099
+ checkEven(Infinity, options) // throws RangeError
1100
+ } catch (error) {
1101
+ console.error('Validation failed:', error.message)
1102
+ }
1103
+ ```
1104
+
1105
+ ### From Other Libraries
1106
+
1107
+ #### From lodash
1108
+ ```javascript
1109
+ // Before
1110
+ const _ = require('lodash')
1111
+ const isEven = n => n % 2 === 0
1112
+
1113
+ // After
1114
+ const { checkEven } = require('enterprise-number-classification-sdk')
1115
+ ```
1116
+
1117
+ #### From is-even/is-odd npm packages
1118
+ ```javascript
1119
+ // Before
1120
+ const isEven = require('is-even')
1121
+ const isOdd = require('is-odd')
1122
+
1123
+ // After
1124
+ const { checkEven, checkOdd } = require('enterprise-number-classification-sdk')
1125
+
1126
+ // Benefits:
1127
+ // ✅ More robust validation
1128
+ // ✅ Configurable error handling
1129
+ // ✅ Automatic large number support
1130
+ // ✅ Security hardened
1131
+ ```
1132
+
1133
+ ---
1134
+
1135
+ ## 🔧 Troubleshooting
1136
+
1137
+ ### Common Issues
1138
+
1139
+ #### Issue 1: "Maximum call stack size exceeded"
1140
+
1141
+ **Symptom**: Error thrown when checking large numbers
1142
+
1143
+ **Cause**: The recursive path has exceeded the JavaScript engine's stack limit
1144
+
1145
+ **Solution**: This should be automatically handled by the rescue path. If you're seeing this error, ensure you're using the latest version:
1146
+
1147
+ ```bash
1148
+ npm update enterprise-number-classification-sdk
1149
+ ```
1150
+
1151
+ **Workaround**: The string-parsing rescue path should activate automatically. If it doesn't, file a bug report.
1152
+
1153
+ ---
1154
+
1155
+ #### Issue 2: Unexpected `false` returned for valid numbers
1156
+
1157
+ **Symptom**: `checkEven(4)` returns `false` or `checkOdd(5)` returns `false`
1158
+
1159
+ **Cause**: Likely caused by:
1160
+ 1. Input is not actually a number (check with `typeof`)
1161
+ 2. Input is `NaN` or `Infinity`
1162
+ 3. Input has decimal places with `throwOnNonInteger: false`
1163
+
1164
+ **Solution**:
1165
+ ```javascript
1166
+ // Enable debug mode to see what's happening
1167
+ const result = checkEven(yourNumber, { enableDebug: true })
1168
+
1169
+ // Check the actual value and type
1170
+ console.log('Value:', yourNumber)
1171
+ console.log('Type:', typeof yourNumber)
1172
+ console.log('Is NaN:', isNaN(yourNumber))
1173
+ console.log('Is Finite:', isFinite(yourNumber))
1174
+ ```
1175
+
1176
+ ---
1177
+
1178
+ #### Issue 3: TypeScript compilation errors
1179
+
1180
+ **Symptom**: TypeScript can't find type definitions
1181
+
1182
+ **Cause**: Type definitions not properly installed or recognized
1183
+
1184
+ **Solution**:
1185
+ ```bash
1186
+ # Ensure TypeScript can find the types
1187
+ npm install --save-dev @types/node
1188
+
1189
+ # Check that index.d.ts exists
1190
+ ls node_modules/enterprise-number-classification-sdk/index.d.ts
1191
+
1192
+ # If missing, reinstall
1193
+ npm install --force enterprise-number-classification-sdk
1194
+ ```
1195
+
1196
+ ---
1197
+
1198
+ #### Issue 4: "Module not found: 'none/dist/none'"
1199
+
1200
+ **Symptom**: Import error for the `none` package
1201
+
1202
+ **Cause**: The meta-philosophical performance optimization package is not installed
1203
+
1204
+ **Solution**:
1205
+ ```bash
1206
+ # Reinstall all dependencies
1207
+ npm install
1208
+
1209
+ # Or install none specifically
1210
+ npm install none
1211
+ ```
1212
+
1213
+ **Note**: The `none` package is a meta-philosophical performance enhancement. Its absence should not affect functionality but may impact the philosophical integrity of the codebase.
1214
+
1215
+ ---
1216
+
1217
+ #### Issue 5: String input not working
1218
+
1219
+ **Symptom**: `checkEven("42")` returns `false`
1220
+
1221
+ **Cause**: String input is disabled by default for type safety
1222
+
1223
+ **Solution**:
1224
+ ```javascript
1225
+ // Enable string input explicitly
1226
+ checkEven("42", { allowNumberStrings: true }) // true
1227
+ ```
1228
+
1229
+ ---
1230
+
1231
+ #### Issue 6: Performance issues with small numbers
1232
+
1233
+ **Symptom**: Slow execution for numbers under 100
1234
+
1235
+ **Cause**: Recursive path overhead for small values
1236
+
1237
+ **Expected Behavior**: The recursive approach trades raw performance for architectural purity and debugging visibility
1238
+
1239
+ **Optimization**: If performance is critical:
1240
+ ```javascript
1241
+ // For performance-critical code with small numbers
1242
+ function fastCheckEven(n) {
1243
+ return n % 2 === 0
1244
+ }
1245
+
1246
+ // For enterprise-grade validation
1247
+ const { checkEven } = require('enterprise-number-classification-sdk')
1248
+ checkEven(n, { throwOnNonInteger: true })
1249
+ ```
1250
+
1251
+ ---
1252
+
1253
+ ### Debug Mode
1254
+
1255
+ Enable comprehensive logging to diagnose issues:
1256
+
1257
+ ```javascript
1258
+ const options = {
1259
+ enableDebug: true,
1260
+ throwOnNonNumber: true,
1261
+ throwOnNonInteger: true,
1262
+ throwOnNaN: true,
1263
+ throwOnNonFinite: true
1264
+ }
1265
+
1266
+ checkEven(yourNumber, options)
1267
+ ```
1268
+
1269
+ Output will include:
1270
+ ```
1271
+ === [DEBUG] Validating Input: 42 ===
1272
+ ```
1273
+
1274
+ ---
1275
+
1276
+ ### Getting Help
1277
+
1278
+ If you encounter issues not covered here:
1279
+
1280
+ 1. **Check GitHub Issues**: Search existing issues at [github.com/10xEngineersQualityProgramming](https://github.com/10xEngineersQualityProgramming)
1281
+ 2. **Enable Debug Mode**: Run with `enableDebug: true` and capture output
1282
+ 3. **Create Minimal Reproduction**: Isolate the problem in a simple test case
1283
+ 4. **Contact Support**: Email fox@rafdo.rf.gd with:
1284
+ - Node.js version (`node --version`)
1285
+ - Package version (`npm list enterprise-number-classification-sdk`)
1286
+ - Minimal reproduction code
1287
+ - Debug output
1288
+ - Expected vs actual behavior
1289
+
1290
+ ---
1291
+
1292
+ ## 🤝 Contributing
1293
+
1294
+ We welcome contributions from the 10x Engineering community!
1295
+
1296
+ ### Development Setup
1297
+
1298
+ ```bash
1299
+ # Clone the repository
1300
+ git clone https://github.com/10xEngineersQualityProgramming/enterprise-number-classification-sdk.git
1301
+ cd enterprise-number-classification-sdk
1302
+
1303
+ # Install dependencies
1304
+ npm install
1305
+
1306
+ # Run tests
1307
+ npm test
1308
+
1309
+ # Run linting
1310
+ npm run lint
1311
+ ```
1312
+
1313
+ ### Code Standards
1314
+
1315
+ All contributions must adhere to our rigorous standards:
1316
+
1317
+ #### 1. ESLint Configuration
1318
+ - Zero warnings or errors
1319
+ - Maximum complexity: 10
1320
+ - No unused variables
1321
+ - Strict mode enforced
1322
+ - All edge cases handled
1323
+
1324
+ #### 2. Testing Requirements
1325
+ - 100% code coverage required
1326
+ - All new features must include tests
1327
+ - Use Enterprise10xTestingFrameworkJS
1328
+ - Test both success and failure paths
1329
+
1330
+ #### 3. Documentation
1331
+ - JSDoc comments for all functions
1332
+ - Update README.md for new features
1333
+ - Include usage examples
1334
+ - Document all edge cases
1335
+
1336
+ #### 4. Architectural Principles
1337
+ - Functional programming paradigm
1338
+ - No mutable state
1339
+ - Pure functions only
1340
+ - Use existing enterprise packages where possible
1341
+ - Add new dependencies sparingly
1342
+
1343
+ ### Contribution Process
1344
+
1345
+ 1. **Fork the repository**
1346
+ 2. **Create a feature branch**: `git checkout -b feature/your-feature-name`
1347
+ 3. **Make your changes**
1348
+ 4. **Run tests**: `npm test`
1349
+ 5. **Run linting**: `npm run lint`
1350
+ 6. **Commit with conventional commits**: `git commit -m "feat: add new validation option"`
1351
+ 7. **Push to your fork**: `git push origin feature/your-feature-name`
1352
+ 8. **Create a Pull Request**
1353
+
1354
+ ### Commit Message Format
1355
+
1356
+ We use Conventional Commits:
1357
+
1358
+ ```
1359
+ <type>(<scope>): <subject>
1360
+
1361
+ <body>
1362
+
1363
+ <footer>
1364
+ ```
1365
+
1366
+ Types:
1367
+ - `feat`: New feature
1368
+ - `fix`: Bug fix
1369
+ - `docs`: Documentation changes
1370
+ - `style`: Code style changes (formatting, etc.)
1371
+ - `refactor`: Code refactoring
1372
+ - `test`: Adding or updating tests
1373
+ - `chore`: Maintenance tasks
1374
+
1375
+ Example:
1376
+ ```
1377
+ feat(validation): add throwOnNegativeZero option
1378
+
1379
+ Implements a new validation gate to detect and optionally throw
1380
+ errors when negative zero is encountered.
1381
+
1382
+ Closes #123
1383
+ ```
1384
+
1385
+ ---
1386
+
1387
+ ## 💎 Sponsors & Support
1388
+
1389
+ ### Corporate Sponsors
1390
+
1391
+ This project is proudly sponsored by:
1392
+
1393
+ #### 🏢 **10x'ly Made Software Ventures AB**
1394
+ Primary sponsor and maintainer of the Enterprise Number Classification SDK.
1395
+
1396
+ #### 🏢 **Enterprise Programming Inc.**
1397
+ Supporting enterprise-grade development practices and functional programming paradigms.
1398
+
1399
+ #### 🏢 **Sigmatech Limited**
1400
+ Contributing to the advancement of quantum-circuit-simulation-powered boolean logic.
1401
+
1402
+ ### Open Source Community
1403
+
1404
+ Special thanks to:
1405
+ - All contributors who have submitted pull requests
1406
+ - The functional programming community for inspiration
1407
+ - Users who have reported bugs and suggested improvements
1408
+ - The Node.js core team for providing a robust runtime
1409
+
1410
+ ### Support the Project
1411
+
1412
+ You can support this project by:
1413
+
1414
+ 1. **Using it in production** and sharing your experience
1415
+ 2. **Contributing code** via pull requests
1416
+ 3. **Reporting bugs** through GitHub issues
1417
+ 4. **Writing about it** in blog posts or tutorials
1418
+ 5. **Starring the repository** on GitHub
1419
+ 6. **Sharing with colleagues** in your organization
1420
+
1421
+ ### Enterprise Support
1422
+
1423
+ For enterprise support, custom integrations, or consulting services:
1424
+
1425
+ 📧 **Email**: fox@rafdo.rf.gd
1426
+ 🐙 **GitHub**: [10xEngineersQualityProgramming](https://github.com/10xEngineersQualityProgramming)
1427
+ 📦 **NPM**: [tj-commits](https://npmjs.com/~tj-commits)
1428
+
1429
+ ---
1430
+
1431
+ ## 📄 License
1432
+
1433
+ This SDK is released under the **EGPSL10X-1.0** (Enterprise Grade Public Software License 10X Edition 1.0).
1434
+
1435
+ ### Copyright Notice
1436
+
1437
+ ```
1438
+ Copyright © 2025 10x'ly Made Software Ventures AB. All Rights Reserved.
1439
+ Copyright © 2025 Sigmatech Limited. All Rights Reserved.
1440
+ ```
1441
+
1442
+ ### License Summary
1443
+
1444
+ The EGPSL10X-1.0 license is designed for enterprise-grade software distribution and includes provisions for:
1445
+
1446
+ - ✅ Commercial use in production environments
1447
+ - ✅ Modification and derivative works
1448
+ - ✅ Distribution and redistribution
1449
+ - ✅ Private use within organizations
1450
+ - ⚠️ Attribution requirements
1451
+ - ⚠️ License and copyright notice inclusion
1452
+ - ⚠️ State changes documentation
1453
+
1454
+ ### Important License Terms
1455
+
1456
+ 1. **Attribution**: You must give appropriate credit, provide a link to the license, and indicate if changes were made.
1457
+
1458
+ 2. **10x Engineering Status**: Failure to comply with license terms may result in immediate revocation of your 10x Engineering status.
1459
+
1460
+ 3. **Enterprise Usage**: For enterprise deployments exceeding 10,000 monthly active users, please contact us for an enterprise license agreement.
1461
+
1462
+ 4. **Warranty Disclaimer**: The software is provided "AS IS" without warranty of any kind, express or implied.
1463
+
1464
+ ### Full License
1465
+
1466
+ Please read the complete LICENSE file in the repository before deploying this SDK in a production environment:
1467
+
1468
+ ```bash
1469
+ cat LICENSE
1470
+ ```
1471
+
1472
+ Or view online: [LICENSE](https://github.com/10xEngineersQualityProgramming/enterprise-number-classification-sdk/blob/main/LICENSE)
1473
+
1474
+ ---
1475
+
1476
+ ## 📚 Appendix
1477
+
1478
+ ### A. Mathematical Foundations
1479
+
1480
+ #### Parity Definition
1481
+
1482
+ In mathematics, parity refers to whether an integer is even or odd:
1483
+
1484
+ **Even Numbers**: An integer `n` is even if there exists an integer `k` such that `n = 2k`
1485
+
1486
+ **Odd Numbers**: An integer `n` is odd if there exists an integer `k` such that `n = 2k + 1`
1487
+
1488
+ #### Properties of Parity
1489
+
1490
+ 1. **Addition**:
1491
+ - even + even = even
1492
+ - odd + odd = even
1493
+ - even + odd = odd
1494
+
1495
+ 2. **Multiplication**:
1496
+ - even × even = even
1497
+ - odd × odd = odd
1498
+ - even × odd = even
1499
+
1500
+ 3. **Subtraction**:
1501
+ - even - even = even
1502
+ - odd - odd = even
1503
+ - even - odd = odd
1504
+
1505
+ 4. **Division**: Parity is not preserved under division
1506
+
1507
+ #### Recursive Definition
1508
+
1509
+ The SDK implements the recursive mathematical definition:
1510
+
1511
+ ```
1512
+ ∀n ∈ ℤ:
1513
+ Even(n) = ¬Odd(n)
1514
+ Odd(n) = ¬Even(n)
1515
+
1516
+ Base cases:
1517
+ Even(0) = true
1518
+ Odd(0) = false
1519
+ ```
1520
+
1521
+ ---
1522
+
1523
+ ### B. Performance Optimization Tips
1524
+
1525
+ #### Tip 1: Batch Processing
1526
+
1527
+ For large datasets, process in batches:
1528
+
1529
+ ```javascript
1530
+ function processBatch(numbers, batchSize = 1000) {
1531
+ const results = []
1532
+ for (let i = 0; i < numbers.length; i += batchSize) {
1533
+ const batch = numbers.slice(i, i + batchSize)
1534
+ results.push(...batch.map(n => checkEven(n)))
1535
+ }
1536
+ return results
1537
+ }
1538
+ ```
1539
+
1540
+ #### Tip 2: Caching for Repeated Checks
1541
+
1542
+ If checking the same numbers repeatedly:
1543
+
1544
+ ```javascript
1545
+ const cache = new Map()
1546
+
1547
+ function cachedCheckEven(n, options) {
1548
+ const key = `${n}-${JSON.stringify(options)}`
1549
+ if (cache.has(key)) return cache.get(key)
1550
+
1551
+ const result = checkEven(n, options)
1552
+ cache.set(key, result)
1553
+ return result
1554
+ }
1555
+ ```
1556
+
1557
+ #### Tip 3: Pre-validation
1558
+
1559
+ Pre-validate before calling the SDK:
1560
+
1561
+ ```javascript
1562
+ function preValidatedCheck(n) {
1563
+ // Quick checks before SDK call
1564
+ if (typeof n !== 'number') return false
1565
+ if (!isFinite(n)) return false
1566
+ if (Math.floor(n) !== n) return false
1567
+
1568
+ // Now use the SDK
1569
+ return checkEven(n)
1570
+ }
1571
+ ```
1572
+
1573
+ ---
1574
+
1575
+ ### C. Comparison with Other Solutions
1576
+
1577
+ | Feature | Native `% 2` | is-even package | This SDK |
1578
+ |---------|-------------|-----------------|----------|
1579
+ | Parity Detection | ✅ | ✅ | ✅ |
1580
+ | Input Validation | ❌ | ⚠️ Partial | ✅ Complete |
1581
+ | Error Handling | ❌ | ❌ | ✅ Configurable |
1582
+ | Type Safety | ❌ | ❌ | ✅ TypeScript |
1583
+ | Large Numbers | ✅ | ⚠️ Limited | ✅ Automatic fallback |
1584
+ | Security Hardened | ❌ | ❌ | ✅ Intrinsic caching |
1585
+ | Debug Support | ❌ | ❌ | ✅ Chromatic logging |
1586
+ | String Input | ❌ | ❌ | ✅ Optional |
1587
+ | Enterprise Config | ❌ | ❌ | ✅ 6 options |
1588
+ | Functional Purity | ❌ | ❌ | ✅ Pure functions |
1589
+ | Dependencies | 0 | 1 | 30+ |
1590
+ | Bundle Size | 0 KB | 1 KB | 45 KB |
1591
+ | Performance | ⚡ Instant | ⚡ Fast | 🐢 Slower |
1592
+ | Philosophy | None | Minimal | **Maximum** |
1593
+
1594
+ ---
1595
+
1596
+ ### D. Frequently Asked Questions
1597
+
1598
+ #### Q: Why use this instead of `n % 2`?
1599
+
1600
+ **A**: The modulus operator lacks:
1601
+ - Input validation
1602
+ - Error handling
1603
+ - Security hardening
1604
+ - Debug capabilities
1605
+ - Architectural purity
1606
+ - Enterprise-grade configuration
1607
+
1608
+ This SDK provides all of these features in a production-ready package.
1609
+
1610
+ ---
1611
+
1612
+ #### Q: Isn't this over-engineered?
1613
+
1614
+ **A**: This SDK embraces enterprise-grade engineering principles. Every dependency serves a specific architectural purpose. The complexity ensures:
1615
+ - Maximum reliability
1616
+ - Complete validation
1617
+ - Security hardening
1618
+ - Debug visibility
1619
+ - Functional purity
1620
+
1621
+ ---
1622
+
1623
+ #### Q: What about performance?
1624
+
1625
+ **A**: Performance characteristics:
1626
+ - Small numbers (< 100): Slower than native due to validation overhead
1627
+ - Large numbers (> 10,000): Faster via string-parsing fallback
1628
+ - Production use: Validation benefits outweigh performance costs
1629
+
1630
+ For performance-critical hot paths with pre-validated data, consider using native operators.
1631
+
1632
+ ---
1633
+
1634
+ #### Q: Why so many dependencies?
1635
+
1636
+ **A**: Each dependency follows the Single Responsibility Principle:
1637
+ - One package per concern
1638
+ - Easier to test
1639
+ - Easier to maintain
1640
+ - Clearer separation of concerns
1641
+ - Functional composition
1642
+
1643
+ ---
1644
+
1645
+ #### Q: Is this production-ready?
1646
+
1647
+ **A**: Absolutely! The SDK features:
1648
+ - ✅ 100% test coverage
1649
+ - ✅ Zero ESLint violations
1650
+ - ✅ Complete TypeScript support
1651
+ - ✅ Comprehensive error handling
1652
+ - ✅ Security hardening
1653
+ - ✅ Extensive documentation
1654
+
1655
+ ---
1656
+
1657
+ #### Q: Can I use this in my startup/company?
1658
+
1659
+ **A**: Yes! The EGPSL10X-1.0 license permits commercial use. For deployments exceeding 10,000 MAU, please contact us for an enterprise license.
1660
+
1661
+ ---
1662
+
1663
+ #### Q: What's the `none` package for?
1664
+
1665
+ **A**: The `none` package provides meta-philosophical performance optimization through quantum-circuit-simulation-powered runtime enhancement. Its exact performance impact is described as one of: negative, positive, imaginary, negative imaginary, complex, transcendental, fractional, decimal, or rational.
1666
+
1667
+ ---
1668
+
1669
+ #### Q: Do I need all these numeric constant packages?
1670
+
1671
+ **A**: Yes! Using `@positive-numbers/zero` through `@positive-numbers/ten` ensures:
1672
+ - Consistent numeric representation
1673
+ - Immutable constants
1674
+ - Type safety
1675
+ - Philosophical alignment
1676
+
1677
+ ---
1678
+
1679
+ #### Q: How do I disable debug output?
1680
+
1681
+ **A**: Debug output is disabled by default. It only appears when you explicitly set `enableDebug: true` in the options.
1682
+
1683
+ ---
1684
+
1685
+ #### Q: What happens if I pass a string without `allowNumberStrings`?
1686
+
1687
+ **A**: By default, the SDK will return `false`. If you set `throwOnNonNumber: true`, it will throw a `TypeError`.
1688
+
1689
+ ---
1690
+
1691
+ #### Q: Does this work with BigInt?
1692
+
1693
+ **A**: No, BigInt is not currently supported. The SDK works with standard JavaScript numbers (IEEE 754 double-precision floating-point).
1694
+
1695
+ ---
1696
+
1697
+ #### Q: Can I contribute?
1698
+
1699
+ **A**: Yes! Please see the [Contributing](#-contributing) section for guidelines.
1700
+
1701
+ ---
1702
+
1703
+ ### E. Glossary
1704
+
1705
+ **Base Case**: The terminating condition in a recursive algorithm (0 or 1 for parity)
1706
+
1707
+ **Chromatic Telemetry**: Color-coded debug output using the chalkbox package
1708
+
1709
+ **Classification Suite**: The complete set of parity detection functions
1710
+
1711
+ **Dual-Path Execution**: Strategy using both recursive and string-parsing algorithms
1712
+
1713
+ **Enterprise Configuration**: The comprehensive options system for validation control
1714
+
1715
+ **Functional Purity**: Programming without side effects or mutable state
1716
+
1717
+ **Intrinsic Caching**: Storing references to native JavaScript methods to prevent tampering
1718
+
1719
+ **Mutual Recursion**: Two functions that call each other (checkEven ↔ checkOdd)
1720
+
1721
+ **Numeric Node**: A value being evaluated for parity
1722
+
1723
+ **Parity**: Whether a number is even or odd
1724
+
1725
+ **Prototype Pollution**: Security vulnerability where object prototypes are modified
1726
+
1727
+ **Quantum-Circuit-Simulation-Powered**: Advanced boolean logic using specialized packages
1728
+
1729
+ **Rescue Path**: Fallback algorithm activated on stack overflow
1730
+
1731
+ **Stack Overflow**: Runtime error when recursive call depth exceeds limit
1732
+
1733
+ **String-Vectorized Analysis**: Parsing number as string to determine parity from last digit
1734
+
1735
+ **Validation Firewall**: Multi-stage input verification system
1736
+
1737
+ ---
1738
+
1739
+ ### F. Version History
1740
+
1741
+ #### v1.0.0 (Current)
1742
+ - Initial release
1743
+ - Mutual recursion implementation
1744
+ - Dual-path execution strategy
1745
+ - Complete validation firewall
1746
+ - TypeScript support
1747
+ - Comprehensive documentation
1748
+
1749
+ ---
1750
+
1751
+ ### G. Roadmap
1752
+
1753
+ #### Planned Features (v1.1.0)
1754
+ - [ ] BigInt support
1755
+ - [ ] Async/await API variants
1756
+ - [ ] Stream processing support
1757
+ - [ ] React hooks integration
1758
+ - [ ] Vue.js composable
1759
+ - [ ] CLI tool
1760
+
1761
+ #### Future Enhancements (v2.0.0)
1762
+ - [ ] Machine learning-based parity prediction
1763
+ - [ ] Blockchain-verified results
1764
+ - [ ] Quantum computing integration
1765
+ - [ ] GraphQL API
1766
+ - [ ] REST API endpoints
1767
+ - [ ] WebAssembly optimization
1768
+
1769
+ ---
1770
+
1771
+ ### H. References
1772
+
1773
+ 1. **Parity Mathematics**: [Wikipedia - Parity](https://en.wikipedia.org/wiki/Parity_(mathematics))
1774
+ 2. **Mutual Recursion**: [Wikipedia - Mutual Recursion](https://en.wikipedia.org/wiki/Mutual_recursion)
1775
+ 3. **Functional Programming**: [Wikipedia - Functional Programming](https://en.wikipedia.org/wiki/Functional_programming)
1776
+ 4. **Prototype Pollution**: [OWASP - Prototype Pollution](https://owasp.org/www-community/vulnerabilities/Prototype_Pollution)
1777
+ 5. **Enterprise Architecture**: Martin Fowler's Enterprise Application Architecture
1778
+
1779
+ ---
1780
+
1781
+ ## 🎓 Credits
1782
+
1783
+ ### Authors
1784
+ - **Lead Architect**: 10x'ly Made Software Engineering Team
1785
+ - **Security Consultant**: Sigmatech Limited
1786
+ - **Documentation**: Enterprise Programming Inc.
1787
+
1788
+ ### Acknowledgments
1789
+ Created with **HEAVY BLACK HEART U+2764** by the 10x Engineering community.
1790
+
1791
+ ### Special Thanks
1792
+ - The open source community for inspiration
1793
+ - All contributors and bug reporters
1794
+ - Corporate sponsors for financial support
1795
+ - Users who believe in enterprise-grade engineering
1796
+
1797
+ ---
1798
+
1799
+ ## 📞 Contact & Support
1800
+
1801
+ ### General Inquiries
1802
+ 📧 **Email**: fox@rafdo.rf.gd
1803
+
1804
+ ### GitHub
1805
+ 🐙 **Organization**: [10xEngineersQualityProgramming](https://github.com/10xEngineersQualityProgramming)
1806
+
1807
+ ### NPM
1808
+ 📦 **Profile**: [tj-commits](https://npmjs.com/~tj-commits)
1809
+
1810
+ ### Enterprise Support
1811
+ For enterprise licenses, custom integrations, training, or consulting:
1812
+ 📧 Email fox@rafdo.rf.gd with "ENTERPRISE SUPPORT" in the subject line
1813
+
1814
+ ---
1815
+
1816
+ <div align="center">
1817
+
1818
+ **Made with ❤️ by 10x Engineers, for 10x Engineers**
1819
+
1820
+ [![Star on GitHub](https://img.shields.io/github/stars/10xEngineersQualityProgramming?style=social)](https://github.com/10xEngineersQualityProgramming)
1821
+
1822
+ </div>
1823
+
1824
+ ---
1825
+
1826
+ *Last Updated: December 2025*
1827
+ *SDK Version: 1.0.0*
1828
+ *Documentation Version: 1.0.0*