New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@semantic-ui/utils

Package Overview
Dependencies
Maintainers
0
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semantic-ui/utils - npm Package Compare versions

Comparing version 0.0.29 to 0.0.30

2

package.json

@@ -11,3 +11,3 @@ {

},
"version": "0.0.29"
"version": "0.0.30"
}

@@ -78,3 +78,3 @@ /*

return key;
}
};

@@ -401,2 +401,39 @@ /*-------------------

export const joinWords = (words, {
separator = ', ',
lastSeparator = ' and ',
oxford = true,
quotes = false,
transform = null
} = {}) => {
if (!isArray(words) || words.length === 0) {
return '';
}
const processedWords = words.map(word => {
let processed = word;
if (isFunction(transform)) {
processed = transform(word);
}
return quotes ? `"${processed}"` : processed;
});
if (processedWords.length === 1) {
return processedWords[0];
}
if (processedWords.length === 2) {
return processedWords.join(lastSeparator);
}
const lastWord = processedWords.pop();
let result = processedWords.join(separator);
if (oxford && separator.trim() !== lastSeparator.trim()) {
result += separator.trim();
}
return result + lastSeparator + lastWord;
};
export const getArticle = (word, settings = {}) => {

@@ -403,0 +440,0 @@ const vowels = ['a', 'e', 'i', 'o', 'u'];

@@ -39,2 +39,3 @@ import { describe, expect, it, vi } from 'vitest';

isString,
joinWords,
kebabToCamel,

@@ -1277,3 +1278,3 @@ keys,

describe('String Conversion', () => {
describe('String Utilities', () => {
it('should correctly convert kebab-case to camelCase', () => {

@@ -1294,2 +1295,70 @@ expect(kebabToCamel('test-string')).toBe('testString');

});
describe('joinWords', () => {
it('should join words with default settings', () => {
const words = ['apple', 'banana', 'cherry'];
expect(joinWords(words)).toBe('apple, banana, and cherry');
});
it('should handle an empty array', () => {
expect(joinWords([])).toBe('');
});
it('should handle a single word', () => {
expect(joinWords(['apple'])).toBe('apple');
});
it('should handle two words', () => {
expect(joinWords(['apple', 'banana'])).toBe('apple and banana');
});
it('should use custom separator', () => {
const words = ['apple', 'banana', 'cherry'];
expect(joinWords(words, { separator: '; ' })).toBe('apple; banana; and cherry');
});
it('should use custom last separator', () => {
const words = ['apple', 'banana', 'cherry'];
expect(joinWords(words, { lastSeparator: ' or ' })).toBe('apple, banana, or cherry');
});
it('should not use Oxford comma when specified', () => {
const words = ['apple', 'banana', 'cherry'];
expect(joinWords(words, { oxford: false })).toBe('apple, banana and cherry');
});
it('should add quotes when specified', () => {
const words = ['apple', 'banana', 'cherry'];
expect(joinWords(words, { quotes: true })).toBe('"apple", "banana", and "cherry"');
});
it('should apply transform function when provided', () => {
const words = ['apple', 'banana', 'cherry'];
const transform = (word) => word.toUpperCase();
expect(joinWords(words, { transform })).toBe('APPLE, BANANA, and CHERRY');
});
it('should handle complex configuration', () => {
const words = ['apple', 'banana', 'cherry', 'date'];
const options = {
separator: '; ',
lastSeparator: ' or ',
oxford: false,
quotes: true,
transform: (word) => word.charAt(0).toUpperCase() + word.slice(1)
};
expect(joinWords(words, options)).toBe('"Apple"; "Banana"; "Cherry" or "Date"');
});
it('should handle non-array input', () => {
expect(joinWords('not an array')).toBe('');
});
it('should handle array with falsy values', () => {
const words = ['apple', '', null, 'banana', undefined, 'cherry'];
expect(joinWords(words)).toBe('apple, , , banana, , and cherry');
});
});
});

@@ -1296,0 +1365,0 @@

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