Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ulu/utils

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ulu/utils - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

10

CHANGELOG.md
# Change Log
## 0.0.9
- Add String (toInitials) Creates initials from string
## 0.0.8
- add number (sum and average)
- Add array (removeDuplicates, createEmptyMatrix)
- Add string (titleCase)
## 0.0.7
Fix missing jsdoc comments in string module. Add linting and fix issues.

@@ -96,2 +96,21 @@ /**

/**
* Converts a string to initials
* - Example "Jane Allen-Doe" --> "JAD"
* - Example (short) "Jane Allen-Doe" --> "JD"
* - Example "Wow this part-time" --> "WTPT"
* - Example "Wow There are 2 !! People." --> "WTA2P"
* @param {String} string String to convert
* @param {Boolean} short If true the initials will be limited to two letters, unless it's only one word which would be single letter
* @returns {String}
*/
export function toInitials(string, short) {
const notAllowed = /[^A-Z0-9\s-]/gi;
const seperators = /[\s-]+/g;
const parts = string.replace(notAllowed, "").split(seperators);
const isShort = short && parts.length > 2;
const final = isShort ? [parts.shift(), parts.pop()] : parts;
return final.map(part => part.substring(0, 1).toUpperCase()).join("");
}
/**
* Convert string to title case

@@ -98,0 +117,0 @@ * @param {String} string String to convert to title case

2

package.json
{
"name": "@ulu/utils",
"version": "0.0.8",
"version": "0.0.9",
"description": "Low level utility library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -55,2 +55,13 @@ /**

/**
* Converts a string to initials
* - Example "Jane Allen-Doe" --> "JAD"
* - Example (short) "Jane Allen-Doe" --> "JD"
* - Example "Wow this part-time" --> "WTPT"
* - Example "Wow There are 2 !! People." --> "WTA2P"
* @param {String} string String to convert
* @param {Boolean} short If true the initials will be limited to two letters, unless it's only one word which would be single letter
* @returns {String}
*/
export function toInitials(string: string, short: boolean): string;
/**
* Convert string to title case

@@ -57,0 +68,0 @@ * @param {String} string String to convert to title case

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc