@stryke/string-format 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
  <!-- prettier-ignore-start -->
3
3
  <!-- markdownlint-disable -->
4
4
 
5
-
6
5
  <div align="center"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/storm-banner.gif" width="100%" alt="Storm Software" /></div>
7
6
  <br />
8
7
 
@@ -22,7 +21,7 @@ This package is part of Storm Software's **đŸŒŠī¸ Stryke** monorepo. Stryke pac
22
21
 
23
22
  <h3 align="center">đŸ’ģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
24
23
 
25
- [![Version](https://img.shields.io/badge/version-0.0.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-0.1.7-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
26
25
 
27
26
  > [!IMPORTANT] This repository, and the apps, libraries, and tools contained
28
27
  > within, is still in it's initial development phase. As a result, bugs and
@@ -38,7 +37,6 @@ This package is part of Storm Software's **đŸŒŠī¸ Stryke** monorepo. Stryke pac
38
37
 
39
38
  <br />
40
39
 
41
-
42
40
  <!-- markdownlint-restore -->
43
41
  <!-- prettier-ignore-end -->
44
42
 
@@ -127,7 +125,6 @@ Run `nx lint string-format` to run [ESLint](https://eslint.org/) on the package.
127
125
  <!-- prettier-ignore-start -->
128
126
  <!-- markdownlint-disable -->
129
127
 
130
-
131
128
  ## Storm Workspaces
132
129
 
133
130
  Storm workspaces are built using
@@ -289,7 +286,6 @@ generation of development tools, please reach out on our
289
286
  <br />
290
287
  <br />
291
288
 
292
-
293
289
  <!-- markdownlint-restore -->
294
290
  <!-- prettier-ignore-end -->
295
291
 
@@ -7,7 +7,7 @@ exports.kebabCase = void 0;
7
7
  var _types = require("@stryke/types");
8
8
  var _upperCaseFirst = require("./upper-case-first.cjs");
9
9
  const kebabCase = t => {
10
- const e = t?.replace(/(?<temp1>[A-Z])+/g, r => (0, _upperCaseFirst.upperCaseFirst)(r) ?? _types.EMPTY_STRING)?.split(/(?=[A-Z])|[\s._-]/).map(r => r.toLowerCase()) ?? [];
10
+ const e = t?.replace(/[A-Z]+/g, r => (0, _upperCaseFirst.upperCaseFirst)(r) ?? _types.EMPTY_STRING)?.split(/(?=[A-Z])|[\s._-]/).map(r => r.toLowerCase()) ?? [];
11
11
  return e.length === 0 ? "" : e.length === 1 ? e[0] : e.reduce((r, s) => `${r}-${s.toLowerCase()}`.toLowerCase());
12
12
  };
13
13
  exports.kebabCase = kebabCase;
@@ -1 +1 @@
1
- import{EMPTY_STRING as n}from"@stryke/types";import{upperCaseFirst as o}from"./upper-case-first";export const kebabCase=t=>{const e=t?.replace(/(?<temp1>[A-Z])+/g,r=>o(r)??n)?.split(/(?=[A-Z])|[\s._-]/).map(r=>r.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((r,s)=>`${r}-${s.toLowerCase()}`.toLowerCase())};
1
+ import{EMPTY_STRING as n}from"@stryke/types";import{upperCaseFirst as o}from"./upper-case-first";export const kebabCase=t=>{const e=t?.replace(/[A-Z]+/g,r=>o(r)??n)?.split(/(?=[A-Z])|[\s._-]/).map(r=>r.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((r,s)=>`${r}-${s.toLowerCase()}`.toLowerCase())};
@@ -13,7 +13,7 @@ const normalizeEmail = e => {
13
13
  let [r] = i.split("+");
14
14
  if (!r) throw new Error("invalid_email_format");
15
15
  r = r.replace(l, "");
16
- const t = r.toLowerCase() + "@" + n.toLowerCase();
16
+ const t = `${r.toLowerCase()}@${n.toLowerCase()}`;
17
17
  return Number(t), t;
18
18
  };
19
19
  exports.normalizeEmail = normalizeEmail;
@@ -6,11 +6,11 @@
6
6
  *
7
7
  * For example, this email
8
8
  *
9
- * Michal.Loler+twitter\@Gmail.com
9
+ * Mike.Johnson+twitter\@Gmail.com
10
10
  *
11
11
  * will be normalized to
12
12
  *
13
- * michalloler\@gmail.com
13
+ * mikejohnson\@gmail.com
14
14
  *
15
15
  */
16
16
  export declare const normalizeEmail: (email: string) => string;
@@ -1 +1 @@
1
- const l=/\./g;export const normalizeEmail=e=>{if(!e.includes("@")&&!e.includes("+"))throw new Error("invalid_email_format");const o=e.split("@").filter(Boolean);if(o.length>1)throw new Error("invalid_email_format");const[i,n]=o;let[r]=i.split("+");if(!r)throw new Error("invalid_email_format");r=r.replace(l,"");const t=r.toLowerCase()+"@"+n.toLowerCase();return Number(t),t};
1
+ const l=/\./g;export const normalizeEmail=e=>{if(!e.includes("@")&&!e.includes("+"))throw new Error("invalid_email_format");const o=e.split("@").filter(Boolean);if(o.length>1)throw new Error("invalid_email_format");const[i,n]=o;let[r]=i.split("+");if(!r)throw new Error("invalid_email_format");r=r.replace(l,"");const t=`${r.toLowerCase()}@${n.toLowerCase()}`;return Number(t),t};
@@ -7,7 +7,7 @@ exports.periodSplit = void 0;
7
7
  var _types = require("@stryke/types");
8
8
  var _upperCaseFirst = require("./upper-case-first.cjs");
9
9
  const periodSplit = e => {
10
- const t = e?.replace(/(?<temp1>[A-Z])+/g, r => (0, _upperCaseFirst.upperCaseFirst)(r) ?? _types.EMPTY_STRING)?.split(/(?=[A-Z])|[\s._-]/).map(r => r.toLowerCase()) ?? [];
10
+ const t = e?.replace(/[A-Z]+/g, r => (0, _upperCaseFirst.upperCaseFirst)(r) ?? _types.EMPTY_STRING)?.split(/(?=[A-Z])|[\s._-]/).map(r => r.toLowerCase()) ?? [];
11
11
  return t.length === 0 ? "" : t.length === 1 ? t[0] : t.reduce((r, n) => `${r}.${n.toLowerCase()}`.toLowerCase());
12
12
  };
13
13
  exports.periodSplit = periodSplit;
@@ -1 +1 @@
1
- import{EMPTY_STRING as s}from"@stryke/types";import{upperCaseFirst as i}from"./upper-case-first";export const periodSplit=e=>{const t=e?.replace(/(?<temp1>[A-Z])+/g,r=>i(r)??s)?.split(/(?=[A-Z])|[\s._-]/).map(r=>r.toLowerCase())??[];return t.length===0?"":t.length===1?t[0]:t.reduce((r,n)=>`${r}.${n.toLowerCase()}`.toLowerCase())};
1
+ import{EMPTY_STRING as s}from"@stryke/types";import{upperCaseFirst as i}from"./upper-case-first";export const periodSplit=e=>{const t=e?.replace(/[A-Z]+/g,r=>i(r)??s)?.split(/(?=[A-Z])|[\s._-]/).map(r=>r.toLowerCase())??[];return t.length===0?"":t.length===1?t[0]:t.reduce((r,n)=>`${r}.${n.toLowerCase()}`.toLowerCase())};
@@ -3,7 +3,7 @@ export interface Options {
3
3
  * Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
4
4
  *
5
5
  * @defaultValue false
6
- * */
6
+ */
7
7
  readonly signed?: boolean;
8
8
  /**
9
9
  * - If `false`: Output won't be localized.
@@ -8,10 +8,10 @@ var _types = require("@stryke/types");
8
8
  var _upperCaseFirst = require("./upper-case-first.cjs");
9
9
  const snakeCase = (t, n) => {
10
10
  if (!t) return "";
11
- const r = t?.replace(/(?<temp1>[A-Z])+/g, e => (0, _upperCaseFirst.upperCaseFirst)(e) ?? _types.EMPTY_STRING).split(/(?=[A-Z])|[\s._-]/).map(e => e.toLowerCase()) ?? [];
11
+ const r = t?.replace(/[A-Z]+/g, e => (0, _upperCaseFirst.upperCaseFirst)(e) ?? _types.EMPTY_STRING).split(/(?=[A-Z])|[\s._-]/).map(e => e.toLowerCase()) ?? [];
12
12
  if (r.length === 0) return "";
13
13
  if (r.length === 1) return r[0];
14
14
  const s = r.reduce((e, i) => `${e}_${i.toLowerCase()}`);
15
- return n?.splitOnNumber === !1 ? s : s.replace(/(?<temp1>[A-Za-z]\d)/, e => `${e[0]}_${e[1]}`);
15
+ return n?.splitOnNumber === !1 ? s : s.replace(/[A-Z]\d/i, e => `${e[0]}_${e[1]}`);
16
16
  };
17
17
  exports.snakeCase = snakeCase;
@@ -1 +1 @@
1
- import{EMPTY_STRING as o}from"@stryke/types";import{upperCaseFirst as a}from"./upper-case-first";export const snakeCase=(t,n)=>{if(!t)return"";const r=t?.replace(/(?<temp1>[A-Z])+/g,e=>a(e)??o).split(/(?=[A-Z])|[\s._-]/).map(e=>e.toLowerCase())??[];if(r.length===0)return"";if(r.length===1)return r[0];const s=r.reduce((e,i)=>`${e}_${i.toLowerCase()}`);return n?.splitOnNumber===!1?s:s.replace(/(?<temp1>[A-Za-z]\d)/,e=>`${e[0]}_${e[1]}`)};
1
+ import{EMPTY_STRING as o}from"@stryke/types";import{upperCaseFirst as a}from"./upper-case-first";export const snakeCase=(t,n)=>{if(!t)return"";const r=t?.replace(/[A-Z]+/g,e=>a(e)??o).split(/(?=[A-Z])|[\s._-]/).map(e=>e.toLowerCase())??[];if(r.length===0)return"";if(r.length===1)return r[0];const s=r.reduce((e,i)=>`${e}_${i.toLowerCase()}`);return n?.splitOnNumber===!1?s:s.replace(/[A-Z]\d/i,e=>`${e[0]}_${e[1]}`)};
package/dist/unescape.cjs CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.unescape = unescape;
7
- const n = {
7
+ const e = {
8
8
  "&amp;": "&",
9
9
  "&lt;": "<",
10
10
  "&gt;": ">",
@@ -12,5 +12,5 @@ const n = {
12
12
  "&#39;": "'"
13
13
  };
14
14
  function unescape(t) {
15
- return t.replace(/&(?:amp|lt|gt|quot|#(?<temp1>0+)?39);/g, e => n[e] || "'");
15
+ return t.replace(/&(?:amp|lt|gt|quot|#0*39);/g, n => e[n] || "'");
16
16
  }
package/dist/unescape.mjs CHANGED
@@ -1 +1 @@
1
- const n={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"};export function unescape(t){return t.replace(/&(?:amp|lt|gt|quot|#(?<temp1>0+)?39);/g,e=>n[e]||"'")}
1
+ const e={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"};export function unescape(t){return t.replace(/&(?:amp|lt|gt|quot|#0*39);/g,n=>e[n]||"'")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/string-format",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "A package containing utility functions to transform strings into various formats.",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "private": false,
12
12
  "publishConfig": { "access": "public" },
13
- "dependencies": { "@stryke/helpers": ">=0.2.4", "@stryke/types": ">=0.2.1" },
13
+ "dependencies": { "@stryke/helpers": ">=0.3.0", "@stryke/types": ">=0.4.0" },
14
14
  "devDependencies": {},
15
15
  "sideEffects": false,
16
16
  "files": ["dist/**/*"],