# craydent-string

> Node module to extend string functionality and simplify code for maintainability and readability

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

## Install

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

## 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 | 45 |
| Unpacked size | 87 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Clark Inada |
| Maintainers | craydent |
| Keywords | craydent, es6, jquery, library, string, sugar, template, utilities |

## Links

- npm: https://www.npmjs.com/package/craydent-string
- 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-string

## Dependencies (45)

- [craydent.cut](https://npm.io/package/craydent.cut.md) 1.0.2
- [craydent.count](https://npm.io/package/craydent.count.md) 1.0.2
- [craydent.error](https://npm.io/package/craydent.error.md) 1.0.2
- [craydent.ltrim](https://npm.io/package/craydent.ltrim.md) 1.0.2
- [craydent.rtrim](https://npm.io/package/craydent.rtrim.md) 1.0.2
- [craydent.strip](https://npm.io/package/craydent.strip.md) 1.0.2
- [craydent.equals](https://npm.io/package/craydent.equals.md) 1.0.2
- [craydent.iscuid](https://npm.io/package/craydent.iscuid.md) 1.0.2
- [craydent.cstring](https://npm.io/package/craydent.cstring.md) 1.0.2
- [craydent.include](https://npm.io/package/craydent.include.md) 1.0.2
- [craydent.isarray](https://npm.io/package/craydent.isarray.md) 1.0.2
- [craydent.isblank](https://npm.io/package/craydent.isblank.md) 1.0.2
- [craydent.reverse](https://npm.io/package/craydent.reverse.md) 1.0.2
- [craydent.condense](https://npm.io/package/craydent.condense.md) 1.0.2
- [craydent.contains](https://npm.io/package/craydent.contains.md) 1.0.2
- [craydent.ellipsis](https://npm.io/package/craydent.ellipsis.md) 1.0.2
- [craydent.endswith](https://npm.io/package/craydent.endswith.md) 1.0.2
- [craydent.getvalue](https://npm.io/package/craydent.getvalue.md) 1.0.2
- [craydent.isstring](https://npm.io/package/craydent.isstring.md) 1.0.2
- [craydent.sanitize](https://npm.io/package/craydent.sanitize.md) 1.0.2
- [craydent.toobject](https://npm.io/package/craydent.toobject.md) 1.0.2
- [craydent.enditwith](https://npm.io/package/craydent.enditwith.md) 1.0.2
- [craydent.globalize](https://npm.io/package/craydent.globalize.md) 1.0.2
- [craydent.highlight](https://npm.io/package/craydent.highlight.md) 1.0.2
- [craydent.pluralize](https://npm.io/package/craydent.pluralize.md) 1.0.2
- [craydent.acronymize](https://npm.io/package/craydent.acronymize.md) 1.0.2
- [craydent.capitalize](https://npm.io/package/craydent.capitalize.md) 1.0.2
- [craydent.indexofalt](https://npm.io/package/craydent.indexofalt.md) 1.0.2
- [craydent.replaceall](https://npm.io/package/craydent.replaceall.md) 1.0.2
- [craydent.startswith](https://npm.io/package/craydent.startswith.md) 1.0.2
- [craydent.todatetime](https://npm.io/package/craydent.todatetime.md) 1.0.2
- [craydent.endswithany](https://npm.io/package/craydent.endswithany.md) 1.0.2
- [craydent.ireplaceall](https://npm.io/package/craydent.ireplaceall.md) 1.0.2
- [craydent.randomindex](https://npm.io/package/craydent.randomindex.md) 1.0.2
- [craydent.singularize](https://npm.io/package/craydent.singularize.md) 1.0.2
- [craydent.startitwith](https://npm.io/package/craydent.startitwith.md) 1.0.2
- [craydent.isvalidemail](https://npm.io/package/craydent.isvalidemail.md) 1.0.2
- [craydent.startswithany](https://npm.io/package/craydent.startswithany.md) 1.0.2
- [craydent.universaltrim](https://npm.io/package/craydent.universaltrim.md) 1.0.2
- [craydent.convertutcdate](https://npm.io/package/craydent.convertutcdate.md) 1.0.2
- [craydent.lastindexofalt](https://npm.io/package/craydent.lastindexofalt.md) 1.0.2
- [craydent.substringendat](https://npm.io/package/craydent.substringendat.md) 1.0.2
- [craydent.substringbetween](https://npm.io/package/craydent.substringbetween.md) 1.0.2
- [craydent.substringstartfrom](https://npm.io/package/craydent.substringstartfrom.md) 1.0.2
- [craydent.tocurrencynotation](https://npm.io/package/craydent.tocurrencynotation.md) 1.0.2

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K 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-string/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-string');
$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-string/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-string/global');
logit($c.VERSION);
arr.prototypedMethod(args);
```

## Categories

* [Constants](#markdown-header-constants)
* [String](#markdown-header-string)

<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) |


## Methods

<a name='markdown-header-string'></a>
## String

*** 
#### _acronymize_ 
***

**Info:** String class extension to create an acronym from the given string

**Return:** (String)

**Parameters:**

>* capsOnly: (Boolean) Flag to indicate to use capital letters only.

**Overloads:**

>Parameters
>* match: (RegExp) Pattern to match to qualify the Acronym.

>Parameters
>* capsOnly: (Boolean) Flag to indicate to use capital letters only.
>* delimiter: (String|RegExp) Character or RegExp pattern that delimits the string.

>Parameters
>* match: (RegExp) Pattern to match to qualify the Acronym.
>* delimiter: (String|RegExp) Character or RegExp pattern that delimits the string.

*** 
#### _capitalize_ 
***

**Info:** String class extension to capitalize parts of the string

**Return:** (String)

**Parameters:**

>* pos?: (Int|Int[]) Index of the string to capitalize
>* everyWord?: (Bool) Flag to capital every word

**Overloads:**

>None

*** 
#### _convertUTCDate_ 
***

**Info:** String class extension to convert date string to UTC format

**Return:** (String)

**Parameters:**

>* delimiter: (String) Character that delimits the date string

**Overloads:**

>None

*** 
#### _count_ 
***

**Info:** Object class extension to count the properties in the object/elements in arrays/characters in strings.

**Return:** (Int)

**Parameters:**

>None

**Overloads:**

>Parameters
>* option: (WhereCondition) Query used in Array.where when counting elements in an Array

>Parameters
>* option: (String) Word or phrase to count in the String

>Parameters
>* option: (RegExp) Word or phrase pattern to count in the String

*** 
#### _cut_ 
***

**Info:** String class extension to remove between the provided indexes

**Return:** (String)

**Parameters:**

>* start_index: (Integer) Start index to cut
>* end_index: (Integer) End index to cut
>* replacement?: (String) String to put in place of the cut

**Overloads:**

>None

*** 
#### _ellipsis_ 
***

**Info:** String class extension to shorten by ellipsis

**Return:** (String)

**Parameters:**

>* before: (Int) Number of characters to use before using ellipsis
>* after?: (Int) Number of characters to use after the ellipsis

**Overloads:**

>None

*** 
#### _highlight_ 
***

**Info:** String class extension to surround search words with the given tag(default span) and class (default chighlight)

**Return:** (String)

**Parameters:**

>* search: (String|RegExp) String or Regular expression to search
>* cssClass?: (String) Class to add for highlighting
>* tag?: (String) Tag to use to surround the search

**Overloads:**

>None

*** 
#### _indexOfAlt_ 
***

**Info:** Array class extension to find index of a value based on a callback function & String class extension to find the index based on a regular expression

**Return:** (Integer)

**Parameters:**

>* value: (any) value to find
>* func: (ArrayIterator<T, TResult>) Callback function used to do the comparison

**Overloads:**

>Parameters
>* regex: (RegExp) Regular expression to check value against
>* pos?: (Int) Index offset to start

*** 
#### _ireplaceAll_ 
***

**Info:** String class extension to replace all substrings ignoring case

**Return:** (String)

**Parameters:**

>* replace: (String|String[]) String or Array of strings to replace
>* subject: (String|String[]) String or Array of strings to replace with

**Overloads:**

>None

*** 
#### _ireplace_all_ 
***

**Info:** String class extension to replace all substrings ignoring case

**Return:** (String)

**Parameters:**

>* replace: (String|String[]) String or Array of strings to replace
>* subject: (String|String[]) String or Array of strings to replace with

**Overloads:**

>None

*** 
#### _isBlank_ 
***

**Info:** String class extension to check if the string is empty

**Return:** (Bool)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _isCuid_ 
***

**Info:** String class extension to check if the string is a cuid

**Return:** (Bool)

**Parameters:**

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

**Overloads:**

>None

*** 
#### _isValidEmail_ 
***

**Info:** String class extension to check if string is a valid email

**Return:** (Bool)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _lastIndexOfAlt_ 
***

**Info:** String class extension to find the last index based on a regular expression

**Return:** (Int)

**Parameters:**

>* regex: (RegExp) Regular expression to check value against
>* pos?: (Int) Max index to go up to in the search

**Overloads:**

>None

*** 
#### _ltrim_ 
***

**Info:** String class extension to remove characters from the beginning of the string

**Return:** (String)

**Parameters:**

>* character?: (Char[]) Character to remove

**Overloads:**

>None

*** 
#### _pluralize_ 
***

**Info:** String class extension to do a best guess pluralization of the string

**Return:** (String)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _randomIndex_ 
***

**Info:** Return a random index without the bounds

**Return:** (Number)

**Parameters:**

>* subject?: (String) String to get valid random index

**Overloads:**

>None

*** 
#### _replaceAll_ 
***

**Info:** String class extension to replace all substrings (case sensitive)

**Return:** (String)

**Parameters:**

>* replace: (String|String[]) String or Array of strings to replace
>* subject: (String|String[]) String or Array of strings to replace with

**Overloads:**

>None

*** 
#### _replace_all_ 
***

**Info:** String class extension to replace all substrings (case sensitive)

**Return:** (String)

**Parameters:**

>* replace: (String|String[]) String or Array of strings to replace
>* subject: (String|String[]) String or Array of strings to replace with

**Overloads:**

>None

*** 
#### _reverse_ 
***

**Info:** String class extension to reverse the string

**Return:** (String)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _rtrim_ 
***

**Info:** String class extension to remove characters from the end of the string

**Return:** (String)

**Parameters:**

>* character?: (Char[]) Character to remove

**Overloads:**

>None

*** 
#### _sanitize_ 
***

**Info:** String class extension to remove potential XSS threats

**Return:** (String)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _singularize_ 
***

**Info:** String class extension to do a best guess singularization of the string

**Return:** (String)

**Parameters:**

>None

**Overloads:**

>None

*** 
#### _startItWith_ 
***

**Info:** String class extension to guarantee the original string starts with the passed string

**Return:** (String)

**Parameters:**

>* starting: (String) String to start with

**Overloads:**

>None

*** 
#### _strip_ 
***

**Info:** String class extension to remove characters from the beginning and end of the string

**Return:** (String)

**Parameters:**

>* character?: (Char[]) Character to remove

**Overloads:**

>None

*** 
#### _substringBetween_ 
***

**Info:** String class extension to substring by character instead of using indexes

**Return:** (String)

**Parameters:**

>* start?: (Char) Character to use for the starting index (required if end is not passed)
>* end?: (Char) Character to use for the ending index (required if start is null or undefined)

**Overloads:**

>None

*** 
#### _substringEndAt_ 
***

**Info:** String class extension to substring by character instead of using indexes

**Return:** (String)

**Parameters:**

>* end: (Char) Character to use for the ending index

**Overloads:**

>None

*** 
#### _substringStartFrom_ 
***

**Info:** String class extension to substring by character instead of using indexes

**Return:** (String)

**Parameters:**

>* start: (Char) Character to use for the starting index

**Overloads:**

>None

*** 
#### _toCurrencyNotation_ 
***

**Info:** String class extension to change number to use separater character

**Return:** (String)

**Parameters:**

>* separator?: (Char) Character to use as delimiter

**Overloads:**

>None

*** 
#### _toDateTime_ 
***

**Info:** String class extension to convert string to datetime

**Return:** (Date|String)

**Parameters:**

>* options?: (DateTimeOptions) specs with optional properties:<br />(Bool) gmt<br />(Int) offset<br />(String) format

**Overloads:**

>None

*** 
#### _toObject_ 
***

**Info:** String class extension to convert to JSON

**Return:** (Object)

**Parameters:**

>* assignmentChar?: (Char) Character to use as assignment delimiter. Defaults to '&'.
>* delimiter?: (Char) Character to use as pair delimiter

**Overloads:**

>None

*** 
#### _trim_ 
***

**Info:** String class extension to remove characters from the beginning and end of the string.

**Return:** (Bool)

**Parameters:**

>* character?: (Char[]) Character to remove in the String

**Overloads:**

>None




## Download

 * [GitHub](https://github.com/craydent/node-library/modules/string)
 * [BitBucket](https://bitbucket.org/craydent/node-library/modules/string)
 * [GitLab](https://gitlab.com/craydent/node-library/modules/string)
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-string · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
