yummies 3.0.37 → 3.0.39
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/complex/global-config.d.ts +3 -0
- package/complex/global-config.d.ts.map +1 -1
- package/complex/global-config.js +3 -0
- package/media.d.ts +8 -0
- package/media.d.ts.map +1 -1
- package/media.js +18 -0
- package/package.json +6 -1
- package/random.d.ts +9 -0
- package/random.d.ts.map +1 -0
- package/random.js +15 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { AnyObject } from '../utils/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Создает глобальный конфиг, который может быть доступен в любой точке в коде
|
|
4
|
+
*/
|
|
2
5
|
export declare const createGlobalConfig: <T extends AnyObject>(defaultValue: T, accessSymbol?: any) => T;
|
|
3
6
|
//# sourceMappingURL=global-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/complex/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,gBACtC,CAAC,iBACD,GAAG,MAelB,CAAC"}
|
|
1
|
+
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/complex/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,gBACtC,CAAC,iBACD,GAAG,MAelB,CAAC"}
|
package/complex/global-config.js
CHANGED
package/media.d.ts
CHANGED
|
@@ -9,4 +9,12 @@ export declare const imageToBlob: (imageElement: HTMLImageElement, mimeType?: st
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const renderImage: (urlOrBlob: Blob | string) => Promise<HTMLImageElement>;
|
|
11
11
|
export declare const rotateImage: (image: HTMLImageElement, angle: number) => Promise<HTMLImageElement>;
|
|
12
|
+
interface DecodedDataUrl {
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
data?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function decodeDataUrl(url: string): DecodedDataUrl;
|
|
17
|
+
export declare const isHttpUrl: (url: string) => boolean;
|
|
18
|
+
export declare const isBase64Image: (str: string) => boolean;
|
|
19
|
+
export {};
|
|
12
20
|
//# sourceMappingURL=media.d.ts.map
|
package/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxD;AAED,eAAO,MAAM,SAAS,cAAe,MAAM,GAAG,IAAI,WACsB,CAAC;AAEzE,eAAO,MAAM,UAAU,SAAU,IAAI,SAEpC,CAAC;AAEF,eAAO,MAAM,WAAW,iBACR,gBAAgB,aACpB,MAAM,SAyBjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,cAAe,IAAI,GAAG,MAAM,8BAMhD,CAAC;AAwCL,eAAO,MAAM,WAAW,UAAW,gBAAgB,SAAS,MAAM,8BAajE,CAAC"}
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxD;AAED,eAAO,MAAM,SAAS,cAAe,MAAM,GAAG,IAAI,WACsB,CAAC;AAEzE,eAAO,MAAM,UAAU,SAAU,IAAI,SAEpC,CAAC;AAEF,eAAO,MAAM,WAAW,iBACR,gBAAgB,aACpB,MAAM,SAyBjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,cAAe,IAAI,GAAG,MAAM,8BAMhD,CAAC;AAwCL,eAAO,MAAM,WAAW,UAAW,gBAAgB,SAAS,MAAM,8BAajE,CAAC;AAEF,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAQzD;AAED,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,OAEvC,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAG3C,CAAC"}
|
package/media.js
CHANGED
|
@@ -89,3 +89,21 @@ export const rotateImage = (image, angle) => {
|
|
|
89
89
|
cropImageFromCanvas(context);
|
|
90
90
|
return renderImage(canvas.toDataURL('image/png'));
|
|
91
91
|
};
|
|
92
|
+
/*
|
|
93
|
+
* Returning object which contains base64 data and mime type of passed data url string.
|
|
94
|
+
* */
|
|
95
|
+
export function decodeDataUrl(url) {
|
|
96
|
+
const regex = /^data:(.*);base64,\s?(.*)$/;
|
|
97
|
+
const matches = new RegExp(regex).exec(url);
|
|
98
|
+
return {
|
|
99
|
+
mimeType: matches?.[1],
|
|
100
|
+
data: matches?.[2],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export const isHttpUrl = (url) => {
|
|
104
|
+
return url.startsWith('https://') || url.startsWith('http://');
|
|
105
|
+
};
|
|
106
|
+
export const isBase64Image = (str) => {
|
|
107
|
+
const { mimeType, data } = decodeDataUrl(str);
|
|
108
|
+
return !!(data && mimeType?.startsWith('image/'));
|
|
109
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yummies",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.39",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -143,6 +143,11 @@
|
|
|
143
143
|
"default": "./price.js",
|
|
144
144
|
"types": "./price.d.ts"
|
|
145
145
|
},
|
|
146
|
+
"./random": {
|
|
147
|
+
"import": "./random.js",
|
|
148
|
+
"default": "./random.js",
|
|
149
|
+
"types": "./random.d.ts"
|
|
150
|
+
},
|
|
146
151
|
"./sound": {
|
|
147
152
|
"import": "./sound.js",
|
|
148
153
|
"default": "./sound.js",
|
package/random.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getRandomFloat: <T extends number = number>(min?: number, max?: number) => T;
|
|
2
|
+
export declare const getRandomInt: <T extends number = number>(min?: number, max?: number) => T;
|
|
3
|
+
export declare const getRandomChoice: <T>(arr: T[]) => T;
|
|
4
|
+
export declare const getRandomSizeArray: (min?: number, max?: number) => unknown[];
|
|
5
|
+
export declare const getRandomBool: () => boolean;
|
|
6
|
+
export declare const getMajorRandomBool: () => boolean;
|
|
7
|
+
export declare const getMinorRandomBool: () => boolean;
|
|
8
|
+
export declare const getFrequencyValue: (frequency: number) => boolean;
|
|
9
|
+
//# sourceMappingURL=random.d.ts.map
|
package/random.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,0CAG5C,CAA6C,CAAC;AAEjD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,0CAA8B,CACH,CAAC;AAEzE,eAAO,MAAM,eAAe,GAAI,CAAC,OAAO,CAAC,EAAE,KAAG,CACR,CAAC;AAEvC,eAAO,MAAM,kBAAkB,2CAC4B,CAAC;AAE5D,eAAO,MAAM,aAAa,eAAiC,CAAC;AAE5D,eAAO,MAAM,kBAAkB,eAE9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,eAE9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAe,MAAM,YAElD,CAAC"}
|
package/random.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable sonarjs/pseudo-random */
|
|
2
|
+
export const getRandomFloat = (min = 0, max = 1) => (Math.random() * (max - min) + min);
|
|
3
|
+
export const getRandomInt = (min = 0, max = 1) => min === max ? min : Math.round(getRandomFloat(min, max));
|
|
4
|
+
export const getRandomChoice = (arr) => arr[getRandomInt(0, arr.length - 1)];
|
|
5
|
+
export const getRandomSizeArray = (min = 0, max = 10) => Array.from({ length: getRandomInt(min, max) }).fill(null);
|
|
6
|
+
export const getRandomBool = () => getRandomInt(0, 1) === 1;
|
|
7
|
+
export const getMajorRandomBool = () => {
|
|
8
|
+
return getRandomInt(0, 10) <= 6;
|
|
9
|
+
};
|
|
10
|
+
export const getMinorRandomBool = () => {
|
|
11
|
+
return !getMajorRandomBool();
|
|
12
|
+
};
|
|
13
|
+
export const getFrequencyValue = (frequency) => {
|
|
14
|
+
return Math.random() < frequency;
|
|
15
|
+
};
|