@ibiliaze/stringman 2.1.0 → 3.1.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/dist/index.d.ts +4 -3
- package/dist/index.js +12 -3
- package/package.json +2 -2
- package/src/index.ts +13 -3
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const superTrim: (stringData:
|
|
2
|
-
export declare const megaTrim: (stringData:
|
|
3
|
-
export declare const dp: (int:
|
|
1
|
+
export declare const superTrim: (stringData: string) => string;
|
|
2
|
+
export declare const megaTrim: (stringData: string) => string;
|
|
3
|
+
export declare const dp: (int: number, i: number) => number;
|
|
4
4
|
export declare const getCloudinaryPublicId: (url: string) => string;
|
|
5
5
|
export declare const query: (q: Record<string, any>) => string;
|
|
6
6
|
export declare const select: <T>(keys: (keyof T)[]) => string;
|
|
7
7
|
export declare const extractImageSrcs: (htmlString: string) => any[];
|
|
8
|
+
export declare const getRandomString: (length: number) => string;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractImageSrcs = exports.select = exports.query = exports.getCloudinaryPublicId = exports.dp = exports.megaTrim = exports.superTrim = void 0;
|
|
4
|
-
const superTrim = stringData => stringData.replace(/\s\s+/g, ' ').trim();
|
|
3
|
+
exports.getRandomString = exports.extractImageSrcs = exports.select = exports.query = exports.getCloudinaryPublicId = exports.dp = exports.megaTrim = exports.superTrim = void 0;
|
|
4
|
+
const superTrim = (stringData) => stringData.replace(/\s\s+/g, ' ').trim();
|
|
5
5
|
exports.superTrim = superTrim;
|
|
6
|
-
const megaTrim = stringData => stringData.replace(/\s\s+/g, '');
|
|
6
|
+
const megaTrim = (stringData) => stringData.replace(/\s\s+/g, '');
|
|
7
7
|
exports.megaTrim = megaTrim;
|
|
8
8
|
const dp = (int, i) => (typeof int === 'number' ? +int.toFixed(i) : 0);
|
|
9
9
|
exports.dp = dp;
|
|
@@ -41,3 +41,12 @@ const extractImageSrcs = (htmlString) => {
|
|
|
41
41
|
return imgTags.map(match => match[1]);
|
|
42
42
|
};
|
|
43
43
|
exports.extractImageSrcs = extractImageSrcs;
|
|
44
|
+
const getRandomString = (length) => {
|
|
45
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
46
|
+
let result = '';
|
|
47
|
+
for (let i = 0; i < length; i++) {
|
|
48
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
exports.getRandomString = getRandomString;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiliaze/stringman",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"pub": "npm publish --access public",
|
|
10
|
-
"git": "git add .; git commit -m 'changes'; git tag -a
|
|
10
|
+
"git": "git add .; git commit -m 'changes'; git tag -a v3.1.0 -m 'v3.1.0'; git push origin v3.1.0; git push",
|
|
11
11
|
"push": "npm run build; npm run git; npm run pub"
|
|
12
12
|
},
|
|
13
13
|
"author": "Ibi Hasanli",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const superTrim = stringData => stringData.replace(/\s\s+/g, ' ').trim();
|
|
2
|
-
export const megaTrim = stringData => stringData.replace(/\s\s+/g, '');
|
|
3
|
-
export const dp = (int, i) => (typeof int === 'number' ? +int.toFixed(i) : 0);
|
|
1
|
+
export const superTrim = (stringData: string) => stringData.replace(/\s\s+/g, ' ').trim();
|
|
2
|
+
export const megaTrim = (stringData: string) => stringData.replace(/\s\s+/g, '');
|
|
3
|
+
export const dp = (int: number, i: number) => (typeof int === 'number' ? +int.toFixed(i) : 0);
|
|
4
4
|
export const getCloudinaryPublicId = (url: string): string => {
|
|
5
5
|
try {
|
|
6
6
|
const public_id_with_extension = url.replace(/^https?:\/\/res\.cloudinary\.com\/[^/]+\/image\/upload\/v\d+\//, '');
|
|
@@ -36,3 +36,13 @@ export const extractImageSrcs = (htmlString: string) => {
|
|
|
36
36
|
const imgTags = [...htmlString.matchAll(/<img\s+[^>]*src=["']([^"']+)["'][^>]*>/gi)];
|
|
37
37
|
return imgTags.map(match => match[1]);
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
export const getRandomString = (length: number) => {
|
|
41
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
42
|
+
let result = '';
|
|
43
|
+
for (let i = 0; i < length; i++) {
|
|
44
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
};
|