@tspro/ts-utils-lib 1.3.0 → 1.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.0] - 2025-09-16
4
+ ### Added
5
+ - Utils.Str.charCount(str, ch)
6
+
3
7
  ## [1.3.0] - 2025-07-18
4
8
  ### Added
5
9
  - Utils.Is
package/dist/index.d.mts CHANGED
@@ -247,12 +247,20 @@ declare function insertAt(str: string, pos: number, insertStr: string): string;
247
247
  * @param removeCount
248
248
  */
249
249
  declare function removeAt(str: string, pos: number, removeCount: number): string;
250
+ /**
251
+ * Count number of char in string.
252
+ * @param str
253
+ * @param ch - must be single char.
254
+ * @returns number of chars in string.
255
+ */
256
+ declare function charCount(str: string, ch: string): number;
250
257
  /**
251
258
  * "UndeclaredVariable" => "Undeclared variable"
252
259
  * @param PascalString
253
260
  */
254
261
  declare function makeSentenceFromPascal(PascalString: string): string;
255
262
 
263
+ declare const index$1_charCount: typeof charCount;
256
264
  declare const index$1_chunkString: typeof chunkString;
257
265
  declare const index$1_insertAt: typeof insertAt;
258
266
  declare const index$1_makeSentenceFromPascal: typeof makeSentenceFromPascal;
@@ -261,7 +269,7 @@ declare const index$1_repeatString: typeof repeatString;
261
269
  declare const index$1_replaceAt: typeof replaceAt;
262
270
  declare const index$1_toCharArray: typeof toCharArray;
263
271
  declare namespace index$1 {
264
- export { index$1_chunkString as chunkString, index$1_insertAt as insertAt, index$1_makeSentenceFromPascal as makeSentenceFromPascal, index$1_removeAt as removeAt, index$1_repeatString as repeatString, index$1_replaceAt as replaceAt, index$1_toCharArray as toCharArray };
272
+ export { index$1_charCount as charCount, index$1_chunkString as chunkString, index$1_insertAt as insertAt, index$1_makeSentenceFromPascal as makeSentenceFromPascal, index$1_removeAt as removeAt, index$1_repeatString as repeatString, index$1_replaceAt as replaceAt, index$1_toCharArray as toCharArray };
265
273
  }
266
274
 
267
275
  declare namespace index {
package/dist/index.d.ts CHANGED
@@ -247,12 +247,20 @@ declare function insertAt(str: string, pos: number, insertStr: string): string;
247
247
  * @param removeCount
248
248
  */
249
249
  declare function removeAt(str: string, pos: number, removeCount: number): string;
250
+ /**
251
+ * Count number of char in string.
252
+ * @param str
253
+ * @param ch - must be single char.
254
+ * @returns number of chars in string.
255
+ */
256
+ declare function charCount(str: string, ch: string): number;
250
257
  /**
251
258
  * "UndeclaredVariable" => "Undeclared variable"
252
259
  * @param PascalString
253
260
  */
254
261
  declare function makeSentenceFromPascal(PascalString: string): string;
255
262
 
263
+ declare const index$1_charCount: typeof charCount;
256
264
  declare const index$1_chunkString: typeof chunkString;
257
265
  declare const index$1_insertAt: typeof insertAt;
258
266
  declare const index$1_makeSentenceFromPascal: typeof makeSentenceFromPascal;
@@ -261,7 +269,7 @@ declare const index$1_repeatString: typeof repeatString;
261
269
  declare const index$1_replaceAt: typeof replaceAt;
262
270
  declare const index$1_toCharArray: typeof toCharArray;
263
271
  declare namespace index$1 {
264
- export { index$1_chunkString as chunkString, index$1_insertAt as insertAt, index$1_makeSentenceFromPascal as makeSentenceFromPascal, index$1_removeAt as removeAt, index$1_repeatString as repeatString, index$1_replaceAt as replaceAt, index$1_toCharArray as toCharArray };
272
+ export { index$1_charCount as charCount, index$1_chunkString as chunkString, index$1_insertAt as insertAt, index$1_makeSentenceFromPascal as makeSentenceFromPascal, index$1_removeAt as removeAt, index$1_repeatString as repeatString, index$1_replaceAt as replaceAt, index$1_toCharArray as toCharArray };
265
273
  }
266
274
 
267
275
  declare namespace index {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.3.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.4.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -816,6 +816,7 @@ function isObject2(value) {
816
816
  // src/utils/str/index.ts
817
817
  var str_exports = {};
818
818
  __export(str_exports, {
819
+ charCount: () => charCount,
819
820
  chunkString: () => chunkString,
820
821
  insertAt: () => insertAt,
821
822
  makeSentenceFromPascal: () => makeSentenceFromPascal,
@@ -858,6 +859,14 @@ function insertAt(str, pos, insertStr) {
858
859
  function removeAt(str, pos, removeCount) {
859
860
  return replaceAt(str, pos, removeCount, "");
860
861
  }
862
+ function charCount(str, ch) {
863
+ if (ch.length !== 1 || str.length === 0) return 0;
864
+ let count = 0;
865
+ for (let i = 0; i < str.length; i++) {
866
+ if (str[i] === ch) count++;
867
+ }
868
+ return count;
869
+ }
861
870
  function makeSentenceFromPascal(PascalString) {
862
871
  if (PascalString === "") {
863
872
  return "";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.3.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.4.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __export = (target, all) => {
@@ -789,6 +789,7 @@ function isObject2(value) {
789
789
  // src/utils/str/index.ts
790
790
  var str_exports = {};
791
791
  __export(str_exports, {
792
+ charCount: () => charCount,
792
793
  chunkString: () => chunkString,
793
794
  insertAt: () => insertAt,
794
795
  makeSentenceFromPascal: () => makeSentenceFromPascal,
@@ -831,6 +832,14 @@ function insertAt(str, pos, insertStr) {
831
832
  function removeAt(str, pos, removeCount) {
832
833
  return replaceAt(str, pos, removeCount, "");
833
834
  }
835
+ function charCount(str, ch) {
836
+ if (ch.length !== 1 || str.length === 0) return 0;
837
+ let count = 0;
838
+ for (let i = 0; i < str.length; i++) {
839
+ if (str[i] === ch) count++;
840
+ }
841
+ return count;
842
+ }
834
843
  function makeSentenceFromPascal(PascalString) {
835
844
  if (PascalString === "") {
836
845
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/ts-utils-lib",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,