@ibiliaze/stringman 2.0.0 → 2.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 CHANGED
@@ -4,3 +4,4 @@ export declare const dp: (int: any, i: any) => 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
+ export declare const extractImageSrcs: (htmlString: string) => any[];
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.select = exports.query = exports.getCloudinaryPublicId = exports.dp = exports.megaTrim = exports.superTrim = void 0;
3
+ exports.extractImageSrcs = exports.select = exports.query = exports.getCloudinaryPublicId = exports.dp = exports.megaTrim = exports.superTrim = void 0;
4
4
  const superTrim = stringData => stringData.replace(/\s\s+/g, ' ').trim();
5
5
  exports.superTrim = superTrim;
6
6
  const megaTrim = stringData => stringData.replace(/\s\s+/g, '');
@@ -36,3 +36,8 @@ const select = (keys) => {
36
36
  return keys.join(',');
37
37
  };
38
38
  exports.select = select;
39
+ const extractImageSrcs = (htmlString) => {
40
+ const imgTags = [...htmlString.matchAll(/<img\s+[^>]*src=["']([^"']+)["'][^>]*>/gi)];
41
+ return imgTags.map(match => match[1]);
42
+ };
43
+ exports.extractImageSrcs = extractImageSrcs;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ibiliaze/stringman",
3
- "version": "2.0.0",
3
+ "version": "2.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 v2.0.0 -m 'v2.0.0'; git push origin v2.0.0; git push",
10
+ "git": "git add .; git commit -m 'changes'; git tag -a v2.1.0 -m 'v2.1.0'; git push origin v2.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
@@ -31,3 +31,8 @@ export const query = (q: Record<string, any>): string => {
31
31
  export const select = <T>(keys: (keyof T)[]): string => {
32
32
  return keys.join(',');
33
33
  };
34
+
35
+ export const extractImageSrcs = (htmlString: string) => {
36
+ const imgTags = [...htmlString.matchAll(/<img\s+[^>]*src=["']([^"']+)["'][^>]*>/gi)];
37
+ return imgTags.map(match => match[1]);
38
+ };