{"id":14713,"library":"modapp-utils","title":"ModApp Utilities","description":"ModApp Utilities (modapp-utils) provides a collection of generic utility functions intended for use across the broader ModApp ecosystem of JavaScript packages. These utilities typically cover common programming patterns such as object manipulation (e.g., deep merging, cloning), array helpers, string transformations, event debouncing/throttling, and unique ID generation. As of version 1.8.0, it serves as a foundational library, abstracting common logic to ensure consistency and reduce boilerplate in related ModApp projects. The package does not explicitly detail its release cadence, but incremental updates can be expected to support the evolving ModApp framework. Its key differentiator is its tailored integration and consistency within the ModApp architecture, rather than offering novel utility functions compared to broader libraries like Lodash or Ramda.","status":"active","version":"1.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/jirenius/modapp-utils","tags":["javascript"],"install":[{"cmd":"npm install modapp-utils","lang":"bash","label":"npm"},{"cmd":"yarn add modapp-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add modapp-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS `require` might work in some environments due to transpilation, but native ESM import is the recommended and future-proof approach for modern Node.js and browser environments.","wrong":"const { debounce } = require('modapp-utils');","symbol":"debounce","correct":"import { debounce } from 'modapp-utils';"},{"note":"Individual utilities are typically named exports from the main package entry point. Direct subpath imports are generally not supported unless explicitly documented.","wrong":"import mergeDeep from 'modapp-utils/mergeDeep';","symbol":"mergeDeep","correct":"import { mergeDeep } from 'modapp-utils';"},{"note":"Ensure to use the exact exported name, `generateUUID`, as `uuid` might not be directly exported or could be an internal alias.","wrong":"import { uuid } from 'modapp-utils';","symbol":"generateUUID","correct":"import { generateUUID } from 'modapp-utils';"}],"quickstart":{"code":"import { debounce, mergeDeep, generateUUID } from 'modapp-utils';\n\n// Example 1: Debouncing a function\nconst searchInputHandler = (query) => {\n  console.log('Searching for:', query);\n  // Simulate API call\n};\nconst debouncedSearch = debounce(searchInputHandler, 500);\n\ndocument.addEventListener('DOMContentLoaded', () => {\n  const input = document.createElement('input');\n  input.placeholder = 'Type to search (debounced)';\n  input.onkeyup = (event) => debouncedSearch(event.target.value);\n  document.body.appendChild(input);\n\n  // Example 2: Deep merging objects\n  const defaultConfig = { host: 'localhost', port: 8080, db: { user: 'guest', pass: 'guest' } };\n  const userConfig = { port: 3000, db: { user: 'admin' }, api: { key: process.env.API_KEY ?? '' } };\n  const mergedConfig = mergeDeep(defaultConfig, userConfig);\n  console.log('Merged Configuration:', mergedConfig);\n\n  // Example 3: Generating a UUID\n  const newId = generateUUID();\n  console.log('Generated UUID:', newId);\n\n  // Cleanup for demonstration purposes\n  setTimeout(() => {\n    console.log('Demonstration complete. Open your browser console.');\n    input.remove();\n  }, 2000);\n});","lang":"typescript","description":"This quickstart demonstrates importing and using a `debounce` function for event handling, a `mergeDeep` function for recursively combining objects, and a `generateUUID` function for creating unique identifiers. It sets up a simple debounced search input in the browser and logs merged configuration and a new UUID to the console."},"warnings":[{"fix":"Always refer to the official documentation or source code for exact export names and types. Use named imports (`import { funcName } from 'modapp-utils';`) unless a default export is explicitly provided.","message":"As a utility library, `modapp-utils` likely exports numerous functions. Incorrectly importing non-existent functions or attempting to import a default export when only named exports are available will result in runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your project is configured for ESM (e.g., `\"type\": \"module\"` in `package.json` or `.mjs` file extension). If using CommonJS, consider transpiling your code or using a bundler that handles ESM imports correctly. Check if a CommonJS build is provided or a legacy version is available if ESM migration is not an option.","message":"Older versions of `modapp-utils` (prior to major version bumps, if any occurred) might have exclusively used CommonJS. Modern versions are likely ESM-first, which can cause `ERR_REQUIRE_ESM` errors in CommonJS-only Node.js environments.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use a modern bundler like Webpack, Rollup, or Vite. Verify bundle size with tools like `webpack-bundle-analyzer` and ensure your bundler is configured for production mode to enable tree-shaking and minification. If bundle size remains an issue, consider selectively importing only the specific utilities you need if the library supports subpath imports (which is not guaranteed for generic utility packages).","message":"While utility libraries are often prime candidates for tree-shaking, the effectiveness of tree-shaking for `modapp-utils` depends on its internal structure and how it's bundled. If not properly implemented, unused utility functions might still be included in your final bundle, increasing its size.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify the exact name of the exported function from `modapp-utils`. Ensure you are using named imports: `import { debounce } from 'modapp-utils';`.","cause":"Attempting to use a named export like `debounce` after an incorrect import, or if `debounce` was not exported or renamed.","error":"TypeError: (0, modapp_utils__WEBPACK_IMPORTED_MODULE_0__.debounce) is not a function"},{"fix":"Either convert your consuming file to an ES Module (by using `import` statements and ensuring your `package.json` has `\"type\": \"module\"` or your file ends in `.mjs`), or use dynamic `import('modapp-utils')` if you must remain in CommonJS.","cause":"`modapp-utils` is an ES Module, but it is being imported into a CommonJS module using `require()`.","error":"ERR_REQUIRE_ESM: require() of ES Module path/to/node_modules/modapp-utils/index.js from path/to/your/file.js not supported. Instead change the require of index.js to a dynamic import() call."},{"fix":"Double-check the `modapp-utils` documentation or its source code to confirm the correct export name for the deep merge utility. It might be named `deepMerge`, `assignDeep`, or similar. Adjust your import statement accordingly.","cause":"The module `modapp-utils` does not export a symbol named `mergeDeep`, or it is exported under a different name, or the module itself is incorrectly structured.","error":"SyntaxError: Named export 'mergeDeep' not found. The requested module 'modapp-utils' does not provide an export named 'mergeDeep'"}],"ecosystem":"npm"}