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