mazey 5.6.3 → 5.6.5
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/README.md +16 -10
- package/README.zh-CN.md +16 -10
- package/lib/index.cjs.js +2 -2
- package/lib/index.d.ts +53 -73
- package/lib/index.esm.js +2 -2
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -3024,29 +3024,17 @@ declare function removeEvent(type: string, fn?: MazeyFn): void;
|
|
|
3024
3024
|
* Usage:
|
|
3025
3025
|
*
|
|
3026
3026
|
* ```javascript
|
|
3027
|
-
* import {
|
|
3027
|
+
* import { setSessionJSON, getSessionJSON } from "mazey";
|
|
3028
3028
|
*
|
|
3029
|
-
*
|
|
3030
|
-
* const
|
|
3031
|
-
*
|
|
3032
|
-
* const ret2 = getLocalStorage("test");
|
|
3033
|
-
* console.log(ret1, ret2);
|
|
3034
|
-
*
|
|
3035
|
-
* // Wrap the helpers with a project-specific key prefix.
|
|
3036
|
-
* const projectName = "mazey";
|
|
3037
|
-
* function mSetLocalStorage (key, value) {
|
|
3038
|
-
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
3039
|
-
* }
|
|
3040
|
-
*
|
|
3041
|
-
* function mGetLocalStorage (key) {
|
|
3042
|
-
* return getLocalStorage(`${projectName}_${key}`);
|
|
3043
|
-
* }
|
|
3029
|
+
* setSessionJSON("preferences", { theme: "dark" });
|
|
3030
|
+
* const preferences = getSessionJSON("preferences");
|
|
3031
|
+
* console.log(JSON.stringify(preferences));
|
|
3044
3032
|
* ```
|
|
3045
3033
|
*
|
|
3046
3034
|
* Output:
|
|
3047
3035
|
*
|
|
3048
3036
|
* ```text
|
|
3049
|
-
*
|
|
3037
|
+
* {"theme":"dark"}
|
|
3050
3038
|
* ```
|
|
3051
3039
|
*
|
|
3052
3040
|
* @param {string} key Storage key.
|
|
@@ -3054,72 +3042,48 @@ declare function removeEvent(type: string, fn?: MazeyFn): void;
|
|
|
3054
3042
|
* @returns {void} This function does not return a value.
|
|
3055
3043
|
* @category Store
|
|
3056
3044
|
*/
|
|
3057
|
-
declare function
|
|
3045
|
+
declare function setSessionJSON<T>(key: string, value?: T | null): void;
|
|
3058
3046
|
/**
|
|
3059
3047
|
* Read a value from `sessionStorage`, parsing JSON when possible.
|
|
3060
3048
|
*
|
|
3061
3049
|
* Usage:
|
|
3062
3050
|
*
|
|
3063
3051
|
* ```javascript
|
|
3064
|
-
* import {
|
|
3065
|
-
*
|
|
3066
|
-
* setSessionStorage("test", "123");
|
|
3067
|
-
* const ret1 = getSessionStorage("test");
|
|
3068
|
-
* setLocalStorage("test", "123");
|
|
3069
|
-
* const ret2 = getLocalStorage("test");
|
|
3070
|
-
* console.log(ret1, ret2);
|
|
3071
|
-
*
|
|
3072
|
-
* // Wrap the helpers with a project-specific key prefix.
|
|
3073
|
-
* const projectName = "mazey";
|
|
3074
|
-
* function mSetLocalStorage (key, value) {
|
|
3075
|
-
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
3076
|
-
* }
|
|
3052
|
+
* import { setSessionJSON, getSessionJSON } from "mazey";
|
|
3077
3053
|
*
|
|
3078
|
-
*
|
|
3079
|
-
*
|
|
3080
|
-
*
|
|
3054
|
+
* setSessionJSON("preferences", { theme: "dark" });
|
|
3055
|
+
* const preferences = getSessionJSON("preferences");
|
|
3056
|
+
* console.log(JSON.stringify(preferences));
|
|
3081
3057
|
* ```
|
|
3082
3058
|
*
|
|
3083
3059
|
* Output:
|
|
3084
3060
|
*
|
|
3085
3061
|
* ```text
|
|
3086
|
-
*
|
|
3062
|
+
* {"theme":"dark"}
|
|
3087
3063
|
* ```
|
|
3088
3064
|
*
|
|
3089
3065
|
* @param {string} key Storage key.
|
|
3090
3066
|
* @returns The parsed value, raw stored value, or `null` when no value exists.
|
|
3091
3067
|
* @category Store
|
|
3092
3068
|
*/
|
|
3093
|
-
declare function
|
|
3069
|
+
declare function getSessionJSON<T>(key: string): T | null;
|
|
3094
3070
|
/**
|
|
3095
3071
|
* Serialize a value as JSON and store it in `localStorage`.
|
|
3096
3072
|
*
|
|
3097
3073
|
* Usage:
|
|
3098
3074
|
*
|
|
3099
3075
|
* ```javascript
|
|
3100
|
-
* import {
|
|
3101
|
-
*
|
|
3102
|
-
* setSessionStorage("test", "123");
|
|
3103
|
-
* const ret1 = getSessionStorage("test");
|
|
3104
|
-
* setLocalStorage("test", "123");
|
|
3105
|
-
* const ret2 = getLocalStorage("test");
|
|
3106
|
-
* console.log(ret1, ret2);
|
|
3107
|
-
*
|
|
3108
|
-
* // Wrap the helpers with a project-specific key prefix.
|
|
3109
|
-
* const projectName = "mazey";
|
|
3110
|
-
* function mSetLocalStorage (key, value) {
|
|
3111
|
-
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
3112
|
-
* }
|
|
3076
|
+
* import { setLocalJSON, getLocalJSON } from "mazey";
|
|
3113
3077
|
*
|
|
3114
|
-
*
|
|
3115
|
-
*
|
|
3116
|
-
*
|
|
3078
|
+
* setLocalJSON("preferences", { theme: "dark" });
|
|
3079
|
+
* const preferences = getLocalJSON("preferences");
|
|
3080
|
+
* console.log(JSON.stringify(preferences));
|
|
3117
3081
|
* ```
|
|
3118
3082
|
*
|
|
3119
3083
|
* Output:
|
|
3120
3084
|
*
|
|
3121
3085
|
* ```text
|
|
3122
|
-
*
|
|
3086
|
+
* {"theme":"dark"}
|
|
3123
3087
|
* ```
|
|
3124
3088
|
*
|
|
3125
3089
|
* @param {string} key Storage key.
|
|
@@ -3127,43 +3091,59 @@ declare function getSessionStorage<T>(key: string): T | null;
|
|
|
3127
3091
|
* @returns {void} This function does not return a value.
|
|
3128
3092
|
* @category Store
|
|
3129
3093
|
*/
|
|
3130
|
-
declare function
|
|
3094
|
+
declare function setLocalJSON<T>(key: string, value?: T | null): void;
|
|
3131
3095
|
/**
|
|
3132
3096
|
* Read a value from `localStorage`, parsing JSON when possible.
|
|
3133
3097
|
*
|
|
3134
3098
|
* Usage:
|
|
3135
3099
|
*
|
|
3136
3100
|
* ```javascript
|
|
3137
|
-
* import {
|
|
3138
|
-
*
|
|
3139
|
-
* setSessionStorage("test", "123");
|
|
3140
|
-
* const ret1 = getSessionStorage("test");
|
|
3141
|
-
* setLocalStorage("test", "123");
|
|
3142
|
-
* const ret2 = getLocalStorage("test");
|
|
3143
|
-
* console.log(ret1, ret2);
|
|
3144
|
-
*
|
|
3145
|
-
* // Wrap the helpers with a project-specific key prefix.
|
|
3146
|
-
* const projectName = "mazey";
|
|
3147
|
-
* function mSetLocalStorage (key, value) {
|
|
3148
|
-
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
3149
|
-
* }
|
|
3101
|
+
* import { setLocalJSON, getLocalJSON } from "mazey";
|
|
3150
3102
|
*
|
|
3151
|
-
*
|
|
3152
|
-
*
|
|
3153
|
-
*
|
|
3103
|
+
* setLocalJSON("preferences", { theme: "dark" });
|
|
3104
|
+
* const preferences = getLocalJSON("preferences");
|
|
3105
|
+
* console.log(JSON.stringify(preferences));
|
|
3154
3106
|
* ```
|
|
3155
3107
|
*
|
|
3156
3108
|
* Output:
|
|
3157
3109
|
*
|
|
3158
3110
|
* ```text
|
|
3159
|
-
*
|
|
3111
|
+
* {"theme":"dark"}
|
|
3160
3112
|
* ```
|
|
3161
3113
|
*
|
|
3162
3114
|
* @param {string} key Storage key.
|
|
3163
3115
|
* @returns The parsed value, raw stored value, or `null` when no value exists.
|
|
3164
3116
|
* @category Store
|
|
3165
3117
|
*/
|
|
3166
|
-
declare function
|
|
3118
|
+
declare function getLocalJSON<T>(key: string): T | null;
|
|
3119
|
+
/**
|
|
3120
|
+
* Deprecated alias of {@link setSessionJSON}.
|
|
3121
|
+
*
|
|
3122
|
+
* @deprecated Use `setSessionJSON` instead.
|
|
3123
|
+
* @category Store
|
|
3124
|
+
*/
|
|
3125
|
+
declare const setSessionStorage: typeof setSessionJSON;
|
|
3126
|
+
/**
|
|
3127
|
+
* Deprecated alias of {@link getSessionJSON}.
|
|
3128
|
+
*
|
|
3129
|
+
* @deprecated Use `getSessionJSON` instead.
|
|
3130
|
+
* @category Store
|
|
3131
|
+
*/
|
|
3132
|
+
declare const getSessionStorage: typeof getSessionJSON;
|
|
3133
|
+
/**
|
|
3134
|
+
* Deprecated alias of {@link setLocalJSON}.
|
|
3135
|
+
*
|
|
3136
|
+
* @deprecated Use `setLocalJSON` instead.
|
|
3137
|
+
* @category Store
|
|
3138
|
+
*/
|
|
3139
|
+
declare const setLocalStorage: typeof setLocalJSON;
|
|
3140
|
+
/**
|
|
3141
|
+
* Deprecated alias of {@link getLocalJSON}.
|
|
3142
|
+
*
|
|
3143
|
+
* @deprecated Use `getLocalJSON` instead.
|
|
3144
|
+
* @category Store
|
|
3145
|
+
*/
|
|
3146
|
+
declare const getLocalStorage: typeof getLocalJSON;
|
|
3167
3147
|
/**
|
|
3168
3148
|
* Get a cookie value by name.
|
|
3169
3149
|
*
|
|
@@ -4247,5 +4227,5 @@ declare const mazeyCon: Console;
|
|
|
4247
4227
|
*/
|
|
4248
4228
|
declare const timeCon: Console;
|
|
4249
4229
|
|
|
4250
|
-
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateCAGR, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertToHtmlBreaks, convertUnderToCamel, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, derivePackageMetadata, detectVisitorType, doFn, extractElementText, fireEvent, floatFixed, floatToPercent, formatByteSize, formatDate, formatDistanceToNow, formatDurationFromMs, formatLocalDateTime, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionStorage, getSystemTheme, getTTFB, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, inRate, invokeEvent, invokeFn, isArray, isBool, isBoolean, isBrowser, isFunction, isHit, isJSONString, isJsonString, isNonEmptyArray, isNonEmptyObject, isNumber, isPureObject, isSafePWAEnv, isStandalonePWA, isString, isSupportWebp, isSupportedEntryType, isThisHour, isThisMonth, isThisWeek, isThisYear, isToday, isUdfOrNul, isValidCssSelector, isValidData, isValidDate, isValidEmail, isValidHttpUrl, isValidPhoneNumber, isValidUrl, listenMediaQueryChanges, loadCSS, loadImage, loadScript, loadScriptIfUndefined, longestComSubsequence, longestComSubstring, mNow, mTrim, mazeyCon, newLine, onURLChange, parseGitHubRepository, parseJsonSafe, parseLocalDateTime, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveElementTarget, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalStorage, setSessionStorage, setThemePreference, sha256Hex, sleep, subYears, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, watchServiceWorkerUpdates, windowLoaded, zAxiosIsValidRes };
|
|
4230
|
+
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateCAGR, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertToHtmlBreaks, convertUnderToCamel, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, derivePackageMetadata, detectVisitorType, doFn, extractElementText, fireEvent, floatFixed, floatToPercent, formatByteSize, formatDate, formatDistanceToNow, formatDurationFromMs, formatLocalDateTime, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalJSON, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionJSON, getSessionStorage, getSystemTheme, getTTFB, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, inRate, invokeEvent, invokeFn, isArray, isBool, isBoolean, isBrowser, isFunction, isHit, isJSONString, isJsonString, isNonEmptyArray, isNonEmptyObject, isNumber, isPureObject, isSafePWAEnv, isStandalonePWA, isString, isSupportWebp, isSupportedEntryType, isThisHour, isThisMonth, isThisWeek, isThisYear, isToday, isUdfOrNul, isValidCssSelector, isValidData, isValidDate, isValidEmail, isValidHttpUrl, isValidPhoneNumber, isValidUrl, listenMediaQueryChanges, loadCSS, loadImage, loadScript, loadScriptIfUndefined, longestComSubsequence, longestComSubstring, mNow, mTrim, mazeyCon, newLine, onURLChange, parseGitHubRepository, parseJsonSafe, parseLocalDateTime, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveElementTarget, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalJSON, setLocalStorage, setSessionJSON, setSessionStorage, setThemePreference, sha256Hex, sleep, subYears, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, watchServiceWorkerUpdates, windowLoaded, zAxiosIsValidRes };
|
|
4251
4231
|
export type { DerivePackageMetadataOptions, DerivedPackageMetadata, FormatByteSizeOptions, GitHubRepositoryDetails, InvestmentReturnRate, IsSafePWAEnvOptions, LocalDateTimePrecision, PackageManager, PackageManifest, PackageManifestAuthor, PreferenceResult, ResolveElementTargetOptions, ResolvedTheme, ServiceWorkerUpdateCallbacks, ServiceWorkerUpdateWatcher, ThemePreference, VisitorType };
|