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.7 to 0.0.8

local/wildcard-match/wildcard-match.js

26

lib/array.js

@@ -64,2 +64,28 @@ /**

return -1;
}
/**
* Remove duplicate items in array
* @param {Array} array Array to remove duplicates from
* @returns {Array} New array with duplicates removed
*/
export function removeDuplicates(array) {
const set = new Set(array);
return [...set];
}
/**
* Create empty matrix with optional value
* @param {Number} columnCount
* @param {Number} rowCount
* @param {*} value Value to set, default is null
* @returns {Array.Array} Matrix (array of arrays)
*/
export function createEmptyMatrix(columnCount, rowCount, value = null) {
const matrix = [];
while (rowCount) {
matrix.push(Array(columnCount).fill(value));
--rowCount;
}
return matrix;
}

@@ -17,1 +17,17 @@ /**

/**
* Get the average of numbers
* @param {...Number} numbers Numbers to get the average of (use spread to use with array)
* @returns
*/
export function average(...numbers) {
return sum(...numbers) / (numbers.length + 1);
}
/**
* Get the summation of numbers
* @param {...Number} numbers Numbers to be added (use spread to use with array)
*/
export function sum(...numbers) {
return numbers.reduce((a, b) => a + b, 0);
}

@@ -94,1 +94,29 @@ /**

}
/**
* Convert string to title case
* @param {String} string String to convert to title case
* @param {Array} exceptions Array of words that shouldn't be title case, common words are included by default
* @param {Array} defaults Default exceptions incase you want full control
* @returns {String}
*/
export function titleCase(
string,
exceptions = [],
defaults = [
"a", "an", "or", "nor", "is", "and", "to", "in", "per", "on", "for", "by",
"at", "as", "the", "etc"
]
) {
const all = [...defaults, ...exceptions];
// Change each word to uppercase if given word isn't an exception
return string.replace(/\w\S*/g, (txt, offset) => {
// The following uses an regular expression to match words in the replace method
// The ternary return is checking if (the matched word is an exception) and then if
// it is not the first word for a given sentence (offset)
// return it in uppercase. If not it was an exception and is not the first word.
return all.indexOf(txt) > -1 && offset !== 0 ?
txt : txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
});
}

2

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

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

@@ -38,2 +38,16 @@ /**

export function offsetFindIndexOf(array: any[], start: number, callback: Function): number;
/**
* Remove duplicate items in array
* @param {Array} array Array to remove duplicates from
* @returns {Array} New array with duplicates removed
*/
export function removeDuplicates(array: any[]): any[];
/**
* Create empty matrix with optional value
* @param {Number} columnCount
* @param {Number} rowCount
* @param {*} value Value to set, default is null
* @returns {Array.Array} Matrix (array of arrays)
*/
export function createEmptyMatrix(columnCount: number, rowCount: number, value?: any): Array.Array;
//# sourceMappingURL=array.d.ts.map

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

export function isBetween(number: number, min: number, max: number): number;
/**
* Get the average of numbers
* @param {...Number} numbers Numbers to get the average of (use spread to use with array)
* @returns
*/
export function average(...numbers: number[]): number;
/**
* Get the summation of numbers
* @param {...Number} numbers Numbers to be added (use spread to use with array)
*/
export function sum(...numbers: number[]): number;
//# sourceMappingURL=number.d.ts.map

@@ -54,2 +54,10 @@ /**

export function truncate(string: string, max: number, overflowChar?: string): string;
/**
* Convert string to title case
* @param {String} string String to convert to title case
* @param {Array} exceptions Array of words that shouldn't be title case, common words are included by default
* @param {Array} defaults Default exceptions incase you want full control
* @returns {String}
*/
export function titleCase(string: string, exceptions?: any[], defaults?: any[]): string;
//# sourceMappingURL=string.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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