npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

craydent-string

v1.0.2

Published

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

Downloads

61

Readme

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. More detailed documentation on methods can be found at Craydent Methods

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

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

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:(Bool) gmt(Int) offset(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