ag-common 0.0.140 → 0.0.141
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.
|
@@ -34,3 +34,10 @@ export declare function containsInsensitive(str: string, ...args: string[]): boo
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const safeStringify: (obj: unknown, indent?: number) => string;
|
|
36
36
|
export declare const chunkString: (str: string, length: number) => string[];
|
|
37
|
+
/**
|
|
38
|
+
* object to string - can be used for querystring a=b&c=d etc
|
|
39
|
+
* @param raw eg a=b&c=d
|
|
40
|
+
* @param splitKeyValue eg =
|
|
41
|
+
* @param splitKeys eg &
|
|
42
|
+
*/
|
|
43
|
+
export declare function stringToObject(raw: string, splitKeyValue: string, splitKeys: string): Record<string, string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkString = exports.safeStringify = exports.containsInsensitive = exports.replaceRemove = exports.toTitleCase = exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = exports.fromBase64 = exports.toBase64 = void 0;
|
|
3
|
+
exports.stringToObject = exports.chunkString = exports.safeStringify = exports.containsInsensitive = exports.replaceRemove = exports.toTitleCase = exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = exports.fromBase64 = exports.toBase64 = void 0;
|
|
4
4
|
const toBase64 = (str) => Buffer.from(str).toString('base64');
|
|
5
5
|
exports.toBase64 = toBase64;
|
|
6
6
|
const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
@@ -141,3 +141,18 @@ const safeStringify = (obj, indent = 2) => {
|
|
|
141
141
|
exports.safeStringify = safeStringify;
|
|
142
142
|
const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, 'g'));
|
|
143
143
|
exports.chunkString = chunkString;
|
|
144
|
+
/**
|
|
145
|
+
* object to string - can be used for querystring a=b&c=d etc
|
|
146
|
+
* @param raw eg a=b&c=d
|
|
147
|
+
* @param splitKeyValue eg =
|
|
148
|
+
* @param splitKeys eg &
|
|
149
|
+
*/
|
|
150
|
+
function stringToObject(raw, splitKeyValue, splitKeys) {
|
|
151
|
+
const ret = {};
|
|
152
|
+
raw.split(splitKeys).forEach((set) => {
|
|
153
|
+
const [k, v] = set.split(splitKeyValue);
|
|
154
|
+
ret[k] = v;
|
|
155
|
+
});
|
|
156
|
+
return ret;
|
|
157
|
+
}
|
|
158
|
+
exports.stringToObject = stringToObject;
|
|
@@ -2,15 +2,38 @@ import { TLang } from '../../common/helpers/i18n';
|
|
|
2
2
|
import { ICognitoAuth } from './cognito';
|
|
3
3
|
import { AxiosWrapperLite } from './jwt';
|
|
4
4
|
export interface LocationSubset {
|
|
5
|
+
/**
|
|
6
|
+
* slash only path eg /aaa/bbb
|
|
7
|
+
*/
|
|
5
8
|
pathname: string;
|
|
9
|
+
/**
|
|
10
|
+
* eg #aaa
|
|
11
|
+
*/
|
|
6
12
|
hash: string;
|
|
13
|
+
/**
|
|
14
|
+
* up to first slash eg http://aaa.com:1111
|
|
15
|
+
*/
|
|
7
16
|
origin: string;
|
|
17
|
+
/**
|
|
18
|
+
* parse querystring keyvalues
|
|
19
|
+
*/
|
|
8
20
|
query: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* protocol less up to first slash eg aaa.com:1111
|
|
23
|
+
*/
|
|
9
24
|
host: string;
|
|
10
25
|
/**
|
|
11
26
|
* eg http: or https:
|
|
12
27
|
*/
|
|
13
28
|
protocol: string;
|
|
29
|
+
/**
|
|
30
|
+
* full url
|
|
31
|
+
*/
|
|
32
|
+
href: string;
|
|
33
|
+
/**
|
|
34
|
+
* url from first slash eg /aaa/bbb?q=a#111
|
|
35
|
+
*/
|
|
36
|
+
path: string;
|
|
14
37
|
}
|
|
15
38
|
export declare type CacheItems = CacheItem<any>[];
|
|
16
39
|
export interface CacheItem<T> {
|