Craydent Utility
raw JSON → 1.0.2 verified Sat May 09 auth: no javascript
Craydent is an all-inclusive Node.js utility library providing over 100+ methods and constants for common tasks like AJAX, file system operations, GUID generation, MD5 hashing, path manipulation, and object/array extensions. Version 1.0.2 is the latest stable release. It offers three import modes: prototype-extending (default), no-conflict modular, and global. Ships TypeScript types. Differentiators include prototype augmentation, global constants, and built-in AJAX support.
Common errors
error ReferenceError: $c is not defined ↓
cause Used $c without requiring the default mode that sets global $c.
fix
Use require('craydent-utility') before accessing $c, or use require('craydent-utility/noConflict') and assign to a local variable.
error TypeError: arr.prototypedMethod is not a function ↓
cause Prototypes not extended because no-conflict mode was used.
fix
Use require('craydent-utility') (default) to extend prototypes, or call the static version: $c.prototypedMethod(arr, args).
error Cannot find module 'craydent-utility/noConflict' ↓
cause Older version of craydent-utility that doesn't support the noConflict subpath.
fix
Upgrade to version 1.0.0 or later.
Warnings
gotcha Default require adds $c and $g to global scope and extends native prototypes (Array, String, etc.). This can cause conflicts with other libraries. ↓
fix Use require('craydent-utility/noConflict') instead to avoid global pollution and prototype modifications.
gotcha The library does not support ES module (ESM) imports. Attempting import will fail. ↓
fix Use CommonJS require() instead of import.
gotcha Methods like zipit() return string paths; not promises. Asynchronous behavior may not be obvious. ↓
fix Check documentation for return types; use callbacks or promises as indicated.
gotcha Some methods (e.g., _catchAll) are global and cannot be imported selectively; they must be required from the root. ↓
fix Only use the default require when you need global exception handlers.
Install
npm install craydent-utility yarn add craydent-utility pnpm add craydent-utility Imports
- $c (default require) wrong
const $c = require('craydent-utility'); $c.logit('test');correctconst $c = require('craydent-utility/noConflict'); $c.logit('test'); - global constants and prototypes wrong
import { VERSION } from 'craydent-utility';correctrequire('craydent-utility'); console.log($c.VERSION); arr.prototypedMethod(args); - global-only mode wrong
const $c = require('craydent-utility/global'); $c.logit($c.VERSION);correctrequire('craydent-utility/global'); logit($c.VERSION);
Quickstart
// Using no-conflict mode (recommended)
const $c = require('craydent-utility/noConflict');
// Example: AJAX call
$c.ajax('https://api.example.com/data', 'json')
.then(data => console.log('Data:', data))
.catch(err => console.error('Error:', err));
// Example: Generate GUID
const guid = $c.guid();
console.log('GUID:', guid);
// Example: MD5 hash
const hash = $c.md5('hello world');
console.log('MD5:', hash);
// Example: Create directory recursively
$c.mkdir('/tmp/a/b/c', { recursive: true });