# craydent-utility

> Node module to for commonly needed utility functions

Latest version **1.0.2** (published 2024-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install craydent-utility
pnpm add craydent-utility
yarn add craydent-utility
bun add craydent-utility
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-09-20 |
| First published | 2018-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 29 |
| Unpacked size | 49.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Clark Inada |
| Maintainers | craydent |
| Keywords | ajax, cluster, craydent, es6, fs, guid, jquery, library, md5, mkdir, sugar, utilities, utility, uuid, zip |

## Links

- npm: https://www.npmjs.com/package/craydent-utility
- Repository: https://github.com/craydent/Node-Library
- Homepage: https://github.com/craydent/Node-Library/tree/master/modules/typeof
- Issues: https://github.com/craydent/Node-Library/issues
- npm.io page: https://npm.io/package/craydent-utility

## Dependencies (29)

- [craydent.foo](https://npm.io/package/craydent.foo.md) 1.0.2
- [craydent.md5](https://npm.io/package/craydent.md5.md) 1.0.2
- [craydent.now](https://npm.io/package/craydent.now.md) 1.0.2
- [craydent.ajax](https://npm.io/package/craydent.ajax.md) 1.0.2
- [craydent.cout](https://npm.io/package/craydent.cout.md) 1.0.2
- [craydent.cuid](https://npm.io/package/craydent.cuid.md) 1.0.2
- [craydent.noop](https://npm.io/package/craydent.noop.md) 1.0.2
- [craydent.rand](https://npm.io/package/craydent.rand.md) 1.0.2
- [craydent.suid](https://npm.io/package/craydent.suid.md) 1.0.2
- [craydent.wait](https://npm.io/package/craydent.wait.md) 1.0.2
- [craydent.jszip](https://npm.io/package/craydent.jszip.md) 1.0.2
- [craydent.logit](https://npm.io/package/craydent.logit.md) 1.0.2
- [craydent.zipit](https://npm.io/package/craydent.zipit.md) 1.0.2
- [craydent.exclude](https://npm.io/package/craydent.exclude.md) 1.0.2
- [craydent.include](https://npm.io/package/craydent.include.md) 1.0.2
- [craydent.tryeval](https://npm.io/package/craydent.tryeval.md) 1.0.2
- [craydent.catchall](https://npm.io/package/craydent.catchall.md) 1.0.2
- [craydent.parseraw](https://npm.io/package/craydent.parseraw.md) 1.0.2
- [craydent.syncroit](https://npm.io/package/craydent.syncroit.md) 1.0.2
- [craydent.clusterit](https://npm.io/package/craydent.clusterit.md) 1.0.2
- [craydent.globalize](https://npm.io/package/craydent.globalize.md) 1.0.2
- [craydent.namespace](https://npm.io/package/craydent.namespace.md) 1.0.2
- [craydent.clearcache](https://npm.io/package/craydent.clearcache.md) 1.0.2
- [craydent.randomindex](https://npm.io/package/craydent.randomindex.md) 1.0.2
- [craydent.absolutepath](https://npm.io/package/craydent.absolutepath.md) 1.0.2
- [craydent.parseboolean](https://npm.io/package/craydent.parseboolean.md) 1.0.2
- [craydent.runfuncarray](https://npm.io/package/craydent.runfuncarray.md) 1.0.2
- [craydent.mkdirrecursive](https://npm.io/package/craydent.mkdirrecursive.md) 1.0.2
- [craydent.requiredirectory](https://npm.io/package/craydent.requiredirectory.md) 1.0.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-09-20
- 1.0.1 — 2024-08-30
- 1.0.0 — 2024-08-23
- 0.15.2 — 2022-08-19
- 0.15.1 — 2022-08-17
- 0.15.0 — 2022-08-16
- 0.14.0 — 2022-08-15
- 0.13.5 — 2021-09-16
- 0.13.4 — 2021-08-09
- 0.13.3 — 2021-08-08
- 0.13.2 — 2021-08-07
- 0.13.1 — 2021-08-04
- 0.13.0 — 2021-07-15
- 0.12.3 — 2021-07-15
- 0.12.2 — 2021-07-15
- … 22 more at https://npm.io/package/craydent-utility/versions

## README

<img src="http://craydent.com/JsonObjectEditor/img/svgs/craydent-logo.svg" width=75 height=75/>

# Craydent 1.0.2
**by Clark Inada**

Craydent is all inclusive utility library.  There are several ways to use the library in NodeJS.
More detailed documentation on constants can be found at [Craydent Properties](http://www.craydent.com/JsonObjectEditor/docs.html#/property/CraydentNode).
More detailed documentation on methods can be found at [Craydent Methods](http://www.craydent.com/JsonObjectEditor/docs.html#/method/CraydentNode)

```js
// require with prototypes - this require will add prototypes to extend classes and add two constants ($c, $g) to the global space.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-utility');
$c.logit($c.VERSION);
arr.prototypedMethod(args);
```

```js
// require no conflict - this require is the fully modular version with no global constants, prototypes, or methods.
var $c = require('craydent-utility/noConflict');
$c.logit($c.VERSION);
$c.prototypedMethod(arr, args);
```

```js
// require global - this require constants and methods in the global space and add prototypes to extend classes.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-utility/global');
logit($c.VERSION);
arr.prototypedMethod(args);
```

## Categories

* [Constants](#markdown-header-constants)
* [Featured](#markdown-header-featured)
* [Utility](#markdown-header-utility)

<a name='markdown-header-constants'></a>
## Constants

| | | |
| ----- | ----- | ----- |
| CONSOLE_COLORS (Object) |LOCAL_IP (String) |TEMPLATE_TAG_CONFIG (Object) |
DEBUG_MODE (Boolean) |MODULES_LOADED (Object) |TEMPLATE_VARS (Array) |
ERROR_TYPES (Array) |PUBLIC_IP (String) |VERSION (String) |
HTTP_STATUS_TEMPLATE (Object) |RESPONSES (Object) |

<a name='markdown-header-featured'></a>
## Featured

### Utility

*** 
#### _catchAll_ 
***

**Info:** Creates an catch all for exceptions in the current node service.

**Return:** (void)

**Parameters:**

>* callback: (ErrorCallback) Callback function to call when there is an uncaught exception
>* append?: (Boolean) Options to defer, ignore case, etc

**Overloads:**

>None

*** 
#### _zipit_ 
***

**Info:** Download a zip of files from file contents

**Return:** (String)

**Parameters:**

>* files: (FileObject[]) Objects containing properties name for file name and content for file content

**Overloads:**

>Parameters
>* filename: (String) Name of the file
>* content: (String) contents of the file



## Methods

<a name='markdown-header-utility'></a>
## Utility

*** 
#### _absolutePath_ 
***

**Info:** Method to make retrieve the absolute path of the provided path

**Return:** (String)

**Parameters:**

>* path: (String) Path to convert to the absolute path

**Overloads:**

>None

*** 
#### _addObjectPrototype_ 
***

**Info:** Method to extend the Object Class

**Return:** (void)

**Parameters:**

>* name: (String) name of the method to add
>* fn: (Function) method implementation
>* override?: (Bool) if true, override the previously defined prototype

**Overloads:**

>None

*** 
#### _ajax_ 
***

**Info:** Method to make ajax calls

**Return:** (Promise<any>)

**Parameters:**

>* url: (String) End point url
>* returnData?: (AjaxReturnType) Specifies which data to return when using Promise pattern

**Overloads:**

>Parameters
>* params: (AjaxOptions) specs with common properties:<br />(String) url<br />(String) dataType<br />(Mixed) hitch<br />(Function[]) onerror<br />(Function[])onsuccess
>* returnData?: (AjaxReturnType) Specifies which data to return when using Promise pattern

*** 
#### _awaitable_ 
***

**Info:** Makes a value awaitable via a Promise.

**Return:** (Promise<any>)

**Parameters:**

>* value: (AwaitableValue) Value to make awaitable

**Overloads:**

>Parameters
>* func: (Function) Function to make awaitable
>* context: (any) Context to use to execute func.

>Parameters
>* func: (Function) Function to make awaitable
>* callbackIndex: (Integer) Index of callback argument.

>Parameters
>* func: (Function) Function to make awaitable
>* context: (any) Context to use to execute func.
>* callbackIndex: (Integer) Index of callback argument.

>Parameters
>* func: (Function) Function to make awaitable
>* context: (any) Context to use to execute func.
>* callbackIndex: (Integer) Index of callback argument.
>* returnIndex: (Integer) Index of callback argument.

*** 
#### _clearCache_ 
***

**Info:** Clear a module from the require cache.

**Return:** (Bool)

**Parameters:**

>* module?: (String) Single module to remove.

**Overloads:**

>None

*** 
#### _clusterit_ 
***

**Info:** Enable clustering

**Return:** (void)

**Parameters:**

>* callback: (ClusterCallback) Method to call for Workers.  Callback is passed the cluster object as an argument.

**Overloads:**

>None

*** 
#### _cout_ 
***

**Info:** Log to console when DEBUG_MODE is true and when the console is available

**Return:** (void)

**Parameters:**

>* ...infinite: (any) any number of arguments can be passed.

**Overloads:**

>None

*** 
#### _cuid_ 
***

**Info:** Creates a Craydent/Global Unique Identifier

**Return:** (String)

**Parameters:**

>* msFormat?: (Bool) use microsoft format if true

**Overloads:**

>None

*** 
#### _exclude_ 
***

**Info:** Exclude prototyping

**Return:** (void)

**Parameters:**

>* list: (String[]) Array of strings in containing the property to exclude from prototyping.

**Overloads:**

>None

*** 
#### _foo_ 
***

**Info:** Place holder function for a blank function

**Return:** (void)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _include_ 
***

**Info:** Require without erroring when module does not exist.

**Return:** (any|false)

**Parameters:**

>* path: (String) Module or Path to module.
>* refresh?: (Bool) Flag to clear cache for the specific include.

**Overloads:**

>None

*** 
#### _isNull_ 
***

**Info:** Check if a value is Null

**Return:** (Bool|any)

**Parameters:**

>* value: (any) Value to check

**Overloads:**

>Parameters
>* value: (any) Value to check
>* defaultValue: (any) Value to return if null

*** 
#### _logit_ 
***

**Info:** Log to console when DEBUG_MODE is true and when the console is available

**Return:** (void)

**Parameters:**

>* ...infinite: (any) any number of arguments can be passed.

**Overloads:**

>None

*** 
#### _md5_ 
***

**Info:** MD5 encode a string.

**Return:** (String)

**Parameters:**

>* str: (String) String to encode.

**Overloads:**

>None

*** 
#### _mkdirRecursive_ 
***

**Info:** Recursively create folders.

**Return:** (void)

**Parameters:**

>* path: (String) Path to create.
>* callback: (Function) Method to call when directories are created (Gets passed error object as an argument and is null if there were no errors).

**Overloads:**

>None

*** 
#### _namespace_ 
***

**Info:** Adds the class to a namespace instead of the global space

**Return:** (void)

**Parameters:**

>* name: (String) Name of the namespace to add to.
>* clazz: (Class) Class to add to the given namespace
>* fn: (Function) Method to call after the class has been added to the namespace

**Overloads:**

>None

*** 
#### _noop_ 
***

**Info:** Place holder function for a blank function

**Return:** (void)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _now_ 
***

**Info:** Get the DateTime of now

**Return:** (Date|String)

**Parameters:**

>* format?: (String) Format syntax to return formatted string of now

**Overloads:**

>None

*** 
#### _parseBoolean_ 
***

**Info:** Try to parse value to a Boolean (0, 1, '0', and '1' are valid unless strict is set to true).

**Return:** (Bool|undefined)

**Parameters:**

>* value: (any) value to parse as boolean.
>* strict?: (Boolean) Disable parsing of 0, 1, '0', and '1'.

**Overloads:**

>None

*** 
#### _parseRaw_ 
***

**Info:** Creates an evaluable string

**Return:** (String)

**Parameters:**

>* value: (any) value to parse
>* skipQuotes?: (Bool) Flag to skip quotes for strings
>* saveCircular?: (Bool) Flag to save circular references

**Overloads:**

>None

*** 
#### _rand_ 
***

**Info:** Create a random number between two numbers

**Return:** (Number)

**Parameters:**

>* num?1: (Number) Lower bound
>* num2?: (Number) Upper bound
>* inclusive?: (Bool) Flag to include the given numbers

**Overloads:**

>None

*** 
#### _requireDirectory_ 
***

**Info:** Recursively require the entire directory and returns an object containing the required modules.

**Return:** (Promise<any>|any)

**Parameters:**

>* path: (String) Path to directory.
>* options?: (Char) 'r' Flag to use to indicate recursively require, (Char) 's' Flag to indicate use syncronous instead of Promise Pattern

**Overloads:**

>None

*** 
#### _runFuncArray_ 
***

**Info:** Executes array of methods

**Return:** (Bool)

**Parameters:**

>* funcs: (Function[]) Array of methods to execute
>* args: (any[]) Array of arguments to be passed to each method

**Overloads:**

>None

*** 
#### _suid_ 
***

**Info:** Creates a short Craydent/Global Unique Identifier

**Return:** (String)

**Parameters:**

>* length?: (Integer) Custom length of the short unique identifier. Default is 10.

**Overloads:**

>None

*** 
#### _syncroit_ 
***

**Info:** Generator/Async based control flow to allow for more "syncronous" programing structure

**Return:** (Promise<any>)

**Parameters:**

>* func: (GeneratorFunction|AsyncFunction) function to execute

**Overloads:**

>None

*** 
#### _tryEval_ 
***

**Info:** Evaluates an expression without throwing an error

**Return:** (any)

**Parameters:**

>* expression: (any) Expression to evaluate
>* evaluator?: (EvaluatorMethod) Method to use to evaluate the expression

**Overloads:**

>None

*** 
#### _wait_ 
***

**Info:** Stops execution until the condition is satisfied

**Return:** (void)

**Parameters:**

>* condition: (Code) Condition equivalent to js true to resume execution

**Overloads:**

>None

*** 
#### _yieldable_ 
***

**Info:** Makes a value yieldable via a Promise.

**Return:** (Promise<any>)

**Parameters:**

>* value: (YieldableValue) Value to make yieldable

**Overloads:**

>Parameters
>* func: (Function) Function to make yieldable
>* context: (any) Context to use to execute func.

>Parameters
>* func: (Function) Function to make yieldable
>* callbackIndex: (Integer) Index of callback argument.

>Parameters
>* func: (Function) Function to make yieldable
>* context: (any) Context to use to execute func.
>* callbackIndex: (Integer) Index of callback argument.

>Parameters
>* func: (Function) Function to make yieldable
>* context: (any) Context to use to execute func.
>* callbackIndex: (Integer) Index of callback argument.
>* returnIndex: (Integer) Index of callback argument.




## Download

 * [GitHub](https://github.com/craydent/node-library/modules/utility)
 * [BitBucket](https://bitbucket.org/craydent/node-library/modules/utility)
 * [GitLab](https://gitlab.com/craydent/node-library/modules/utility)
Craydent is released under the [Dual licensed under the MIT or GPL Version 2 licenses](http://craydent.com/license).<br>

---
_Source: https://npm.io/package/craydent-utility · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
