Skip to content

Commit

Permalink
improve string-* type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepage committed Apr 28, 2024
1 parent dd41f63 commit d39fe71
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/address/normalize/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/address-normalize",
"description": "A utility that normalizes an address string for ease of parsing",
"version": "2.4.3",
"version": "2.4.4",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/address/parse/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/address-parse",
"description": "An address parser for American and Canadian addresses that breaks down the provided address into its component parts",
"version": "0.1.4",
"version": "0.1.5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/address/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/address",
"description": "A collection of address utilities and parsers",
"version": "2.4.5",
"version": "2.4.6",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/app",
"description": "A modern library/monorepo of high-quality, zero-dependency, fully typed, fully tested, tree-shakeable utilities, parsers, data structure factories, converters and other capabilities ",
"version": "2.8.9",
"version": "2.8.10",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/case/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case",
"description": "A set of utilities to convert the case of strings",
"version": "2.0.9",
"version": "2.0.10",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/geo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/geo",
"description": "A collection of geo parsers",
"version": "2.0.6",
"version": "2.0.7",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/is/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/is",
"description": "A collection of utility methods to determine type, classification or equality",
"version": "2.1.7",
"version": "2.1.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/string/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/string",
"description": "A set of functions to manipulate strings",
"version": "2.0.7",
"version": "2.0.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/to/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/to",
"description": "A set of functions to convert between data types",
"version": "2.0.7",
"version": "2.0.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/utilities/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/utilities",
"description": "A collection of all utilities within the @zerodep ecosystem",
"version": "2.3.7",
"version": "2.3.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/case/camel/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case-camel",
"description": "A utility to convert a string to camelCase",
"version": "2.0.10",
"version": "2.0.11",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/case/dot/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case-dot",
"description": "A utility to convert a string to dot.case",
"version": "2.0.4",
"version": "2.0.5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/case/kebab/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case-kebab",
"description": "A utility to convert a string to kebab-case",
"version": "2.0.10",
"version": "2.0.11",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/case/pascal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case-pascal",
"description": "A utility to convert a string to PascalCase",
"version": "2.0.10",
"version": "2.0.11",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/case/sentence/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case-sentence",
"description": "A utility to convert a string to sentence case",
"version": "2.0.10",
"version": "2.0.11",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/case/snake/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/case-snake",
"description": "A utility to convert a string to snake_case",
"version": "2.0.10",
"version": "2.0.11",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/country/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/geo-country",
"description": "Get info about a country by its name or common abbreviation",
"version": "2.3.4",
"version": "2.3.5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/state/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/geo-state",
"description": "Get info about a state by its name or common abbreviation",
"version": "2.3.4",
"version": "2.3.5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/string/deburr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/string-deburr",
"description": "A utility to convert accented characters to non-accented equivalents",
"version": "2.0.6",
"version": "2.0.7",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/string/deburr/src/lib/stringDeburr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const accentedWords = [
['ſ', 's'],
];

xdescribe('stringDeburr', () => {
describe('stringDeburr', () => {
test.each(accentedWords)(
'should return a non-accented value of %s',
(title, value) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/string/deburr/src/lib/stringDeburr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @source https://en.wikipedia.org/wiki/List_of_Unicode_characters
import { guardString } from '@zerodep/guard-string';

const latinRegex = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
const comboMarkRegex = /[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]/g;
const charMap: Record<string, string> = {
Expand Down Expand Up @@ -197,9 +199,7 @@ const charMap: Record<string, string> = {
};

export const stringDeburr = (value: string): string => {
if (!value) {
return '';
}
guardString(value);

// dev note: yes, you can use a function as the replacer
return value
Expand Down
2 changes: 1 addition & 1 deletion packages/string/trim/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/string-trim",
"description": "A utility to trim whitespace or specific values from the start and end of a string",
"version": "2.0.7",
"version": "2.0.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions packages/string/trim/src/lib/stringTrim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const stringTrim = (value: string, char = ''): string => {
if (char === '') {
return value.trim();
}
guardString(char);

// ensure the character in the regex is regex-safe
const safeChar = ['.', '?'].includes(char) ? `\\${char}` : char;
Expand Down
2 changes: 1 addition & 1 deletion packages/string/words/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/string-words",
"description": "A utility to convert a string into an array of words",
"version": "2.0.7",
"version": "2.0.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions packages/string/words/src/lib/stringWords.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import {ZeroDepError} from '@zerodep/errors';
import { guardString } from '@zerodep/guard-string';
import {isRegex} from '@zerodep/is-regex';
import {isString} from '@zerodep/is-string';
import { stringTrim } from '@zerodep/string-trim';

export const stringWords = (
value: string,
separator: string | RegExp = ' '
): string[] => {
guardString(value);
if (!isString(separator) && !isRegex(separator)) {
throw new ZeroDepError('Separator is not a string or Regex');
}

return value
.split(separator)
Expand Down
2 changes: 1 addition & 1 deletion packages/to/date/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/to-date",
"description": "A utility to convert a value to a Date",
"version": "2.0.8",
"version": "2.0.9",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit d39fe71

Please sign in to comment.