@zuzjs/core 0.3.1 → 0.3.2

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.
@@ -1,82 +0,0 @@
1
- class Events {
2
- _events;
3
- constructor() {
4
- this._events = [];
5
- }
6
- /**
7
- * Registers an event listener.
8
- * @param event The name of the event.
9
- * @param fun The callback function.
10
- * @param context Optional context (this) for the callback.
11
- * @returns A function to unsubscribe this specific listener.
12
- */
13
- on(event, fun, context) {
14
- const evt = this._events.find(x => x.event === event);
15
- const id = Symbol('listener_id'); // Give each listener a unique ID
16
- const listener = {
17
- fun: fun, // Store original function
18
- context: context,
19
- id: id,
20
- };
21
- if (!evt) {
22
- this._events.push({ event: event, listeners: [listener] });
23
- }
24
- else {
25
- evt.listeners.push(listener);
26
- }
27
- // Return an unsubscribe function
28
- return () => {
29
- const currentEvt = this._events.find(x => x.event === event);
30
- if (currentEvt) {
31
- currentEvt.listeners = currentEvt.listeners.filter(l => l.id !== id);
32
- if (currentEvt.listeners.length === 0) {
33
- this._events = this._events.filter(e => e.event !== event);
34
- }
35
- }
36
- };
37
- }
38
- /**
39
- * Removes event listeners matching a specific event and function.
40
- * Note: This removes *all* listeners for the event that use the exact same function reference.
41
- * It's often more reliable to use the unsubscribe function returned by 'on'.
42
- * @param event The name of the event.
43
- * @param fun The callback function to remove.
44
- */
45
- off(event, fun) {
46
- const evt = this._events.find(x => x.event === event);
47
- if (evt) {
48
- // Filter out listeners where the 'fun' property matches the provided function.
49
- evt.listeners = evt.listeners.filter(listener => listener.fun !== fun);
50
- // Optional: If no listeners remain for this event, remove the event entry.
51
- if (evt.listeners.length === 0) {
52
- this._events = this._events.filter(e => e.event !== event);
53
- }
54
- }
55
- }
56
- /**
57
- * Emits an event, calling all registered listeners.
58
- * @param event The name of the event.
59
- * @param args Arguments to pass to the listeners.
60
- */
61
- emit(event, ...args) {
62
- const evt = this._events.find(x => x.event === event);
63
- if (evt) {
64
- [...evt.listeners].forEach(({ fun, context }) => {
65
- try {
66
- fun.apply(context, args);
67
- }
68
- catch (e) {
69
- console.error(`Error during event '${String(event)}' emission:`, e);
70
- }
71
- });
72
- }
73
- }
74
- /**
75
- * Removes all listeners for a specific event.
76
- * @param event The name of the event.
77
- */
78
- removeAllListeners(event) {
79
- this._events = this._events.filter(e => e.event !== event);
80
- }
81
- }
82
- export default Events;
@@ -1,52 +0,0 @@
1
- import { AxiosProgressEvent, AxiosRequestConfig, CancelTokenSource } from "axios";
2
- import { RefObject } from "react";
3
- import { FormatNumberParams, sortOptions } from "./types.js";
4
- export { default as PubSub } from "./events.js";
5
- export { CancelTokenSource, AxiosProgressEvent as UploadProgressEvent };
6
- export * from "./types.js";
7
- export declare const __SALT: string;
8
- export { default as "_" } from "./withGlobals.js";
9
- export declare const numberInRange: (min: number, max: number) => number;
10
- export declare const toHash: (n: number, len?: number, SALT?: string | null) => string;
11
- export declare const fromHash: (str: string, SALT?: string | null) => number;
12
- export declare const MD5: (str: string) => string;
13
- export declare const uuid: (len: number) => string;
14
- export declare const ucfirst: (o: any) => string;
15
- export declare const urldecode: (str: string) => string;
16
- export declare const urlencode: (str: string) => string;
17
- export declare const pluralize: (word: string, count: number) => string;
18
- export declare const isHexColor: (color: string) => boolean;
19
- export declare const isRgbaColor: (color: string) => boolean;
20
- export declare const isHslColor: (color: string) => boolean;
21
- export declare const isColorName: (color: string) => boolean;
22
- export declare const isColor: (color: string) => boolean;
23
- export declare const hexToRgba: (hex: string, alpha?: number) => string;
24
- export declare const removeDuplicates: <T>(array: T[]) => T[];
25
- export declare const getCancelToken: () => CancelTokenSource;
26
- export declare const withCredentials: (include: boolean) => boolean;
27
- export declare const withPost: <T>(uri: string, data: any, // 'dynamic' usually maps to 'any' or 'Record<string, any>'
28
- timeout?: number, ignoreKind?: boolean, headers?: AxiosRequestConfig["headers"], onProgress?: (ev: AxiosProgressEvent) => void) => Promise<T>;
29
- export declare const withGet: <T>(uri: string, timeout?: number, ignoreKind?: boolean, headers?: AxiosRequestConfig["headers"]) => Promise<T>;
30
- export declare const withTime: (fun: (...args: any[]) => any) => {
31
- result: any;
32
- executionTime: number;
33
- };
34
- export declare const time: (stamp?: number, format?: string) => string;
35
- export declare const timeSince: (stamp: number) => string;
36
- export declare const arrayRand: (arr: any[]) => any;
37
- export declare const formatNumber: ({ number, locale, style, decimal, forceDecimal, currency }: FormatNumberParams) => string;
38
- export declare const formatSize: (bytes: number | string) => string;
39
- export declare const copyToClipboard: (text: string) => Promise<unknown>;
40
- export declare const natsort: (options?: sortOptions) => (a: string | number, b: string | number) => number;
41
- export declare const camelCase: (str: string, ucf?: boolean) => string;
42
- export declare const camelCaseToDash: (str: string) => string;
43
- export declare const clamp: (value: number, min: number, max: number) => number;
44
- export declare const slugify: (text: string, separator?: string) => string;
45
- export declare const animateCSSVar: (ref: RefObject<HTMLElement>, variable: string, to: number, { lerpFactor, threshold, multiplier, }?: {
46
- lerpFactor?: number;
47
- threshold?: number;
48
- multiplier?: number;
49
- }) => void;
50
- export declare const sleep: (ms: number) => Promise<any>;
51
- export declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
52
- export declare const exists: (path: string) => Promise<boolean>;
package/dist/cjs/index.js DELETED
@@ -1,381 +0,0 @@
1
- import axios from "axios";
2
- import fs from "fs/promises";
3
- import Hashids from "hashids";
4
- import Cookies from "js-cookie";
5
- import md5 from "md5";
6
- import moment from "moment";
7
- import { colorNames } from "./colors.js";
8
- import { hexColorRegex, hslColorRegex, rgbaColorRegex } from "./regexps.js";
9
- import { SORT } from "./types.js";
10
- import _ from "./withGlobals.js";
11
- export { default as PubSub } from "./events.js";
12
- export * from "./types.js";
13
- export const __SALT = `zuzjs-core`;
14
- export { default as "_" } from "./withGlobals.js";
15
- export const numberInRange = (min, max) => {
16
- return Math.floor(Math.random() * (max - min + 1)) + min;
17
- };
18
- export const toHash = (n, len = 6, SALT = null) => new Hashids(SALT || __SALT, len).encode(n);
19
- export const fromHash = (str, SALT = null) => {
20
- try {
21
- const n = new Hashids(SALT || __SALT, +process.env.HASHIDS_LENGTH).decode(str);
22
- return n.length >= 0 ? Number(n[0]) : 0;
23
- }
24
- catch (e) {
25
- return 0;
26
- }
27
- };
28
- export const MD5 = (str) => md5(str);
29
- export const uuid = (len) => toHash(numberInRange(11111111111, 999999999999));
30
- export const ucfirst = (o) => `${o.charAt(0).toUpperCase()}${o.substring(1, o.length)}`;
31
- export const urldecode = (str) => decodeURIComponent(str.replace(/\+/g, '%20'));
32
- export const urlencode = (str) => encodeURIComponent(str);
33
- export const pluralize = (word, count) => `${word}${count !== 1 ? 's' : ''}`;
34
- export const isHexColor = (color) => hexColorRegex.test(color);
35
- export const isRgbaColor = (color) => rgbaColorRegex.test(color);
36
- export const isHslColor = (color) => hslColorRegex.test(color);
37
- export const isColorName = (color) => colorNames.includes(color.toLowerCase());
38
- // Function to validate a color string
39
- export const isColor = (color) => isHexColor(color) || isRgbaColor(color) || isHslColor(color);
40
- export const hexToRgba = (hex, alpha = 1) => {
41
- // Remove the hash symbol if present
42
- hex = hex.replace(/^#/, '');
43
- // If shorthand hex (#RGB), expand it to full form (#RRGGBB)
44
- if (hex.length === 3) {
45
- hex = hex.split('').map(char => char + char).join('');
46
- }
47
- // Convert to integer values for RGB
48
- const bigint = parseInt(hex, 16);
49
- const r = (bigint >> 16) & 255;
50
- const g = (bigint >> 8) & 255;
51
- const b = bigint & 255;
52
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
53
- };
54
- export const removeDuplicates = (array) => {
55
- return array.reduce((accumulator, currentValue) => {
56
- if (!accumulator.includes(currentValue)) {
57
- accumulator.push(currentValue);
58
- }
59
- return accumulator;
60
- }, []);
61
- };
62
- export const getCancelToken = () => axios.CancelToken.source();
63
- export const withCredentials = (include) => axios.defaults.withCredentials = include;
64
- export const withPost = async (uri, data, // 'dynamic' usually maps to 'any' or 'Record<string, any>'
65
- timeout = 60, ignoreKind = false, headers = {}, onProgress) => {
66
- const _cookies = Cookies.get();
67
- let finalData = data;
68
- let contentType = 'application/json';
69
- // 1. Data Preparation Logic
70
- if (data instanceof FormData) {
71
- contentType = 'multipart/form-data';
72
- for (const [key, value] of Object.entries(_cookies)) {
73
- data.append(key, value);
74
- }
75
- }
76
- else if (typeof data === "object" && !Array.isArray(data) && data !== null) {
77
- // Handle standard objects: inject cookies and timestamp
78
- finalData = {
79
- ...data,
80
- ..._cookies,
81
- __stmp: Date.now() / 1000
82
- };
83
- }
84
- else if (!_(data).isString()) {
85
- // If it's not FormData, an Object, or a String, reject immediately
86
- throw new Error("Unsupported data type for withPost");
87
- }
88
- // 2. Single Axios Execution
89
- try {
90
- const resp = await axios({
91
- method: 'post',
92
- url: uri,
93
- data: finalData,
94
- timeout: timeout * 1000,
95
- headers: {
96
- 'Content-Type': contentType,
97
- ...headers
98
- },
99
- onUploadProgress: onProgress
100
- });
101
- // 3. Response Validation
102
- if (resp.data && (ignoreKind || "kind" in resp.data)) {
103
- return resp.data;
104
- }
105
- else {
106
- throw resp.data;
107
- }
108
- }
109
- catch (err) {
110
- // 4. Centralized Error Handling
111
- if (err?.response?.data) {
112
- throw err.response.data;
113
- }
114
- throw err.code === `ERR_NETWORK`
115
- ? {
116
- error: err.code,
117
- message: navigator.onLine
118
- ? `Unable to connect to the server. It may be temporarily down.`
119
- : `Network error: Unable to connect. Please check your internet connection and try again.`,
120
- }
121
- : err;
122
- }
123
- };
124
- export const withGet = async (uri, timeout = 60, ignoreKind = false, headers = {}) => {
125
- try {
126
- const resp = await axios.get(uri, {
127
- timeout: timeout * 1000,
128
- headers: headers
129
- });
130
- if (resp.data && (ignoreKind || "kind" in resp.data)) {
131
- return resp.data;
132
- }
133
- else {
134
- throw resp.data;
135
- }
136
- }
137
- catch (err) {
138
- if (err?.response?.data) {
139
- throw err.response.data;
140
- }
141
- throw err.code === `ERR_NETWORK`
142
- ? {
143
- error: err.code,
144
- message: navigator.onLine
145
- ? `Unable to connect to the server. It may be temporarily down.`
146
- : `Network error: Unable to connect. Please check your internet connection and try again.`,
147
- }
148
- : err;
149
- }
150
- };
151
- export const withTime = (fun) => {
152
- const start = new Date().getTime();
153
- const result = fun();
154
- const end = new Date().getTime();
155
- return {
156
- result,
157
- executionTime: end - start
158
- };
159
- };
160
- export const time = (stamp, format) => {
161
- return stamp ?
162
- moment.unix(+stamp / 1000).format(format || `YYYY-MM-DD HH:mm:ss`)
163
- : moment().format(format || `YYYY-MM-DD HH:mm:ss`);
164
- };
165
- export const timeSince = (stamp) => moment(stamp).fromNow();
166
- export const arrayRand = (arr) => arr[Math.floor(Math.random() * arr.length)];
167
- export const formatNumber = ({ number, locale = 'en-US', style = `decimal`, decimal = 2, forceDecimal = false, currency }) => {
168
- if (style === 'currency' && !currency) {
169
- throw new TypeError('Currency code is required with currency style.');
170
- }
171
- if (currency) {
172
- const { code, style: currencyStyle, symbol } = currency;
173
- const out = new Intl.NumberFormat(locale, {
174
- style: `currency`,
175
- currency: code,
176
- currencyDisplay: currencyStyle,
177
- minimumFractionDigits: forceDecimal ? decimal : +number % 1 > 0 ? decimal : 0,
178
- maximumFractionDigits: forceDecimal ? decimal : +number % 1 > 0 ? decimal : 0
179
- }).format(+number);
180
- return symbol ? out.replace(new RegExp(`\\${code}`, 'g'), symbol) : out;
181
- }
182
- return new Intl.NumberFormat(locale, {
183
- style,
184
- minimumFractionDigits: forceDecimal ? decimal : +number % 1 > 0 ? 2 : 0,
185
- maximumFractionDigits: forceDecimal ? decimal : +number % 1 > 0 ? 2 : 0
186
- }).format(+number);
187
- };
188
- export const formatSize = (bytes) => {
189
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
190
- const _bytes = `string` == typeof bytes ? parseFloat(bytes) : bytes;
191
- if (_bytes == 0)
192
- return '0 Byte';
193
- const _i = Math.floor(Math.log(_bytes) / Math.log(1024));
194
- const i = `string` == typeof _i ? parseInt(_i) : _i;
195
- const nx = _bytes / Math.pow(1024, i);
196
- return nx.toFixed(2) + ' ' + sizes[i];
197
- };
198
- export const copyToClipboard = (text) => {
199
- if (navigator.clipboard && navigator.clipboard.writeText) {
200
- return navigator.clipboard.writeText(text);
201
- }
202
- else {
203
- return new Promise((resolve, reject) => {
204
- const textarea = document.createElement("textarea");
205
- textarea.value = text;
206
- textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
207
- document.body.appendChild(textarea);
208
- textarea.focus();
209
- textarea.select();
210
- try {
211
- document.execCommand("copy");
212
- resolve(`Copied to clipboard`);
213
- }
214
- catch (err) {
215
- // console.error("Fallback: Oops, unable to copy", err);
216
- reject(err);
217
- }
218
- document.body.removeChild(textarea);
219
- });
220
- }
221
- };
222
- export const natsort = (options = {
223
- direction: SORT.Asc,
224
- caseSensitive: false,
225
- }) => {
226
- const ore = /^0/;
227
- const sre = /\s+/g;
228
- const tre = /^\s+|\s+$/g;
229
- // unicode
230
- const ure = /[^\x00-\x80]/;
231
- // hex
232
- const hre = /^0x[0-9a-f]+$/i;
233
- // numeric
234
- const nre = /(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g;
235
- // datetime
236
- const dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/; // tslint:disable-line
237
- const GREATER = options.direction == SORT.Desc ? -1 : 1;
238
- const SMALLER = -GREATER;
239
- const _normalize = !options.caseSensitive
240
- ? (s) => s.toString().toLowerCase().replace(tre, '')
241
- : (s) => (`${s}`).replace(tre, '');
242
- const _tokenize = (s) => {
243
- return s.replace(nre, '\0$1\0')
244
- .replace(/\0$/, '')
245
- .replace(/^\0/, '')
246
- .split('\0');
247
- };
248
- const _parse = (s, l) => {
249
- return (!s.match(ore) || l === 1) &&
250
- parseFloat(s)
251
- || s.replace(sre, ' ').replace(tre, '')
252
- || 0;
253
- };
254
- return function (a, b) {
255
- const aa = _normalize(a);
256
- const bb = _normalize(b);
257
- if (!aa && !bb) {
258
- return 0;
259
- }
260
- if (!aa && bb) {
261
- return SMALLER;
262
- }
263
- if (aa && !bb) {
264
- return GREATER;
265
- }
266
- const aArr = _tokenize(aa);
267
- const bArr = _tokenize(bb);
268
- // hex or date detection
269
- const aHex = aa.match(hre);
270
- const bHex = bb.match(hre);
271
- const av = (aHex && bHex) ? parseInt(aHex[0], 16) : (aArr.length !== 1 && Date.parse(aa));
272
- const bv = (aHex && bHex)
273
- ? parseInt(bHex[0], 16)
274
- : av && bb.match(dre) && Date.parse(bb) || null;
275
- // try and sort Hex codes or Dates
276
- if (bv) {
277
- if (av === bv) {
278
- return 0;
279
- }
280
- if (typeof av === 'number' && typeof bv === 'number' && av < bv) {
281
- return SMALLER;
282
- }
283
- if (typeof av === 'number' && av > bv) {
284
- return GREATER;
285
- }
286
- }
287
- const al = aArr.length;
288
- const bl = bArr.length;
289
- // handle numeric strings and default strings
290
- for (let i = 0, l = Math.max(al, bl); i < l; i += 1) {
291
- const af = _parse(aArr[i] || '', al);
292
- const bf = _parse(bArr[i] || '', bl);
293
- if (isNaN(af) !== isNaN(bf)) {
294
- return isNaN(af) ? GREATER : SMALLER;
295
- }
296
- if (ure.test(af + bf) && af.localeCompare) {
297
- const comp = af.localeCompare(bf);
298
- if (comp > 0) {
299
- return GREATER;
300
- }
301
- if (comp < 0) {
302
- return SMALLER;
303
- }
304
- if (i === l - 1) {
305
- return 0;
306
- }
307
- }
308
- if (af < bf) {
309
- return SMALLER;
310
- }
311
- if (af > bf) {
312
- return GREATER;
313
- }
314
- if (`${af}` < `${bf}`) {
315
- return SMALLER;
316
- }
317
- if (`${af}` > `${bf}`) {
318
- return GREATER;
319
- }
320
- }
321
- return 0;
322
- };
323
- };
324
- export const camelCase = (str, ucf = false) => {
325
- return str
326
- .toLowerCase()
327
- .split(/[^a-zA-Z0-9]+/) // Split by any non-alphanumeric character
328
- .map((word, index) => index === 0
329
- ? ucf ? ucfirst(word) : word
330
- : ucfirst(word))
331
- .join('');
332
- };
333
- export const camelCaseToDash = (str) => str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
334
- export const clamp = (value, min, max) => {
335
- return Math.min(Math.max(value, min), max);
336
- };
337
- export const slugify = (text, separator = "-") => {
338
- if (undefined == text) {
339
- console.log(text, `is undefined`);
340
- return ``;
341
- }
342
- return text
343
- .normalize("NFKD") // Normalize accents (e.g., é → e)
344
- .replace(/[\u0300-\u036f]/g, "") // Remove diacritic marks
345
- .toLowerCase()
346
- .replace(/[^a-z0-9\p{L}\p{N}]+/gu, separator) // Keep letters/numbers from all languages
347
- .replace(new RegExp(`\\${separator}{2,}`, "g"), separator) // Remove duplicate separators
348
- .replace(new RegExp(`^\\${separator}|\\${separator}$`, "g"), ""); // Trim separators from ends
349
- };
350
- export const animateCSSVar = (ref, variable, to, { lerpFactor = 0.1, threshold = 0.1, multiplier = 1, } = {}) => {
351
- if (!ref.current)
352
- return;
353
- let current = parseFloat(getComputedStyle(ref.current).getPropertyValue(variable)) || 0;
354
- let target = to * multiplier;
355
- let rafId = null;
356
- const tick = () => {
357
- current += (target - current) * lerpFactor;
358
- if (ref.current) {
359
- ref.current.style.setProperty(variable, `${current}px`);
360
- }
361
- if (Math.abs(target - current) > threshold) {
362
- rafId = requestAnimationFrame(tick);
363
- }
364
- };
365
- // Cancel if a new target arrives
366
- if (rafId)
367
- cancelAnimationFrame(rafId);
368
- requestAnimationFrame(tick);
369
- };
370
- export const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
371
- export const enumToKeys = (obj) => Object.keys(obj)
372
- .filter((key) => isNaN(Number(key)));
373
- export const exists = async (path) => {
374
- try {
375
- await fs.access(path);
376
- return true;
377
- }
378
- catch {
379
- return false;
380
- }
381
- };
@@ -1,3 +0,0 @@
1
- export declare const hexColorRegex: RegExp;
2
- export declare const rgbaColorRegex: RegExp;
3
- export declare const hslColorRegex: RegExp;
@@ -1,6 +0,0 @@
1
- // Hex color regex (#RGB, #RRGGBB)
2
- export const hexColorRegex = /^#([A-Fa-f0-9]{3}){1,2}$/;
3
- // RGBA color regex (rgba(255, 255, 255, 1))
4
- export const rgbaColorRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/;
5
- // HSL color regex (hsl(360, 100%, 100%))
6
- export const hslColorRegex = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;
@@ -1,28 +0,0 @@
1
- export type dynamic = {
2
- [x: string]: any;
3
- };
4
- export interface FormatNumberParams {
5
- number: number | string;
6
- locale?: string;
7
- style?: `decimal` | `currency` | `percent`;
8
- decimal?: number;
9
- forceDecimal?: boolean;
10
- currency?: {
11
- code: string;
12
- style: `symbol` | `code` | `name`;
13
- symbol?: string;
14
- };
15
- }
16
- export declare enum SORT {
17
- Asc = "ASC",
18
- Desc = "DESC"
19
- }
20
- export type sortOptions = {
21
- direction?: SORT;
22
- caseSensitive?: boolean;
23
- };
24
- export interface EventListener {
25
- fun: (...args: any[]) => void;
26
- context?: any;
27
- id: symbol;
28
- }
package/dist/cjs/types.js DELETED
@@ -1,5 +0,0 @@
1
- export var SORT;
2
- (function (SORT) {
3
- SORT["Asc"] = "ASC";
4
- SORT["Desc"] = "DESC";
5
- })(SORT || (SORT = {}));
@@ -1,41 +0,0 @@
1
- declare class withGlobals {
2
- _: any;
3
- constructor(value: any);
4
- isIP(): boolean;
5
- isIPv4(): boolean;
6
- isIPv6(): boolean;
7
- isTypeof(v: any): boolean;
8
- isFunction(): boolean;
9
- isArray(): boolean;
10
- isNull(): boolean;
11
- isString(): boolean;
12
- isNumber(): boolean;
13
- isObject(): boolean;
14
- isEmpty(): boolean;
15
- isEmail(): boolean;
16
- isUrl(): boolean;
17
- toLowerCase(): this;
18
- /**
19
- * Performs a deep equality check for arrays and objects, otherwise a strict equality check.
20
- * @param v The value to compare against.
21
- * @returns {boolean} True if the values are equal, false otherwise.
22
- */
23
- equals(v: any): boolean;
24
- private isObjectValue;
25
- ucfirst(): this;
26
- formatString(v: string | number, ...vv: (string | number)[]): this;
27
- camelCase(): this;
28
- /**
29
- * Sorts the keys of the internal object in ascending or descending order.
30
- * If the internal value is not an object, it remains unchanged.
31
- * @param order The sort order: 'asc' for ascending (default), 'desc' for descending.
32
- * @returns {this} The current instance for chaining.
33
- */
34
- sort(order?: 'asc' | 'desc'): this;
35
- value(): any;
36
- valueOf(): any;
37
- toString(): string;
38
- [Symbol.toPrimitive](hint: string): string | number | boolean;
39
- }
40
- declare const _: <T>(value: T) => withGlobals;
41
- export default _;