# Module: 'mcode-data.js'

> MicroCODE Common Data Utitlities LICENSE: -------- MIT License: MicroCODE.mcode-data Copyright (c) 2022-2025 Timothy McGuire, MicroCODE, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. DESCRIPTION: ------------ This module implements the MicroCODE's Common JavaScript functions for data handling. REFERENCES: ----------- 1. MIT xPRO Course: Professional Certificate in Coding: Full Stack Development with MERN. 2. LADDERS® source code: MACRO-11, MACRO-32, C#, and JavaScript. MODIFICATIONS: -------------- Date: By-Group: Rev: Description: 30-Jan-2024 TJM-MCODE {0001} New module for common reusable JavaScript data handling functions. 01-Feb-2024 TJM-MCODE {0002} Changed to the Universal Module Definition (UMD) pattern to support AMD, CommonJS/Node.js, and browser global in our exported module. 01-Feb-2024 TJM-MCODE {0003} Swap() and Call() now throw an error if the 'keys' and 'values' lists are not the same length, instead of logging the error and returning a default value. 22-Aug-2024 TJM-MCODE {0004} Corrected isJson() to rely on 1st character being '{' to determine JSON string it was returning true for any string that contained a '{' character, this was signaling 'true' for HTMX templates that contained '{{variable}}'. 05-Oct-2024 TJM-MCODE {0005} Added 'uuidDecode()' function to decode UUID strings into their component parts. 19-Feb-2025 TJM-MCODE {0006} v0.5.08 - updated 'httpStatus()' to use a STATIC copy of HTTP codes JSON for speed. - updated all UUID string lists to STATIC as well. 17-Apr-2025 TJM-MCODE {0007} v0.5.09 - added 'isHtml()' function to check if a string is HTML, updated 'isJson()' to use same check. 23-Oct-2025 TJM-MCODE {0008} v0.6.03 - added 'classExport()' to return the created class constructor to support SSR and ESM module loading, especially in HTMX applications. Also added: sleep(), ifNumber(), encodeJson(), generateRandomId(). NOTE: This module follows MicroCODE's JavaScript Style Guide and Template JS file, see: o https://github.com/MicroCODEIncorporated/JavaScriptSG o https://github.com/MicroCODEIncorporated/TemplatesJS

Author:
  - Timothy McGuire, MicroCODE, Inc.
Source:
  - index.js, line 5

### Namespaces

mcode