@nejs/basic-extensions 2.8.0 → 2.9.0

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 CHANGED
@@ -450,39 +450,47 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
450
450
  * [randomRGBA](#randomrgba)
451
451
  * [Parameters](#parameters-109)
452
452
  * [Examples](#examples-113)
453
+ * [sgr](#sgr)
454
+ * [Parameters](#parameters-110)
455
+ * [wrap](#wrap)
456
+ * [Parameters](#parameters-111)
457
+ * [Examples](#examples-114)
453
458
  * [isString](#isstring-1)
454
- * [Examples](#examples-114)
455
- * [ifString](#ifstring-1)
456
- * [Parameters](#parameters-110)
457
459
  * [Examples](#examples-115)
458
- * [instance](#instance-2)
460
+ * [ifString](#ifstring-1)
461
+ * [Parameters](#parameters-112)
459
462
  * [Examples](#examples-116)
463
+ * [instance](#instance-2)
464
+ * [Examples](#examples-117)
460
465
  * [extractSubstring](#extractsubstring)
461
- * [Parameters](#parameters-111)
466
+ * [Parameters](#parameters-113)
462
467
  * [StringPrototypeExtensions](#stringprototypeextensions)
463
468
  * [SymbolExtensions](#symbolextensions)
464
- * [withData](#withdata)
465
- * [Parameters](#parameters-112)
466
- * [Examples](#examples-117)
467
469
  * [isSymbol](#issymbol)
468
- * [Parameters](#parameters-113)
469
- * [isRegistered](#isregistered)
470
470
  * [Parameters](#parameters-114)
471
- * [isNonRegistered](#isnonregistered)
471
+ * [isRegistered](#isregistered)
472
472
  * [Parameters](#parameters-115)
473
+ * [isNonRegistered](#isnonregistered)
474
+ * [Parameters](#parameters-116)
473
475
  * [keys](#keys)
474
476
  * [Examples](#examples-118)
477
+ * [withData](#withdata)
478
+ * [Parameters](#parameters-117)
479
+ * [Examples](#examples-119)
475
480
  * [instance](#instance-3)
476
- * [Examples](#examples-119)
477
- * [data](#data)
478
481
  * [Examples](#examples-120)
479
- * [data](#data-1)
480
- * [Parameters](#parameters-116)
482
+ * [data](#data)
481
483
  * [Examples](#examples-121)
482
- * [mightHaveEmbeddedJSON](#mighthaveembeddedjson)
484
+ * [data](#data-1)
485
+ * [Parameters](#parameters-118)
483
486
  * [Examples](#examples-122)
487
+ * [mightHaveEmbeddedJSON](#mighthaveembeddedjson)
488
+ * [Examples](#examples-123)
489
+ * [for](#for)
490
+ * [Parameters](#parameters-119)
491
+ * [Examples](#examples-124)
484
492
  * [Deferred](#deferred)
485
- * [Parameters](#parameters-117)
493
+ * [Parameters](#parameters-120)
486
494
  * [value](#value-1)
487
495
  * [reason](#reason)
488
496
  * [settled](#settled)
@@ -490,11 +498,11 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
490
498
  * [wasResolved](#wasresolved)
491
499
  * [promise](#promise)
492
500
  * [resolve](#resolve)
493
- * [Parameters](#parameters-118)
501
+ * [Parameters](#parameters-121)
494
502
  * [reject](#reject)
495
- * [Parameters](#parameters-119)
496
- * [for](#for)
497
- * [Parameters](#parameters-120)
503
+ * [Parameters](#parameters-122)
504
+ * [for](#for-1)
505
+ * [Parameters](#parameters-123)
498
506
  * [species](#species)
499
507
  * [promise](#promise-1)
500
508
  * [reject](#reject-1)
@@ -502,61 +510,61 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
502
510
  * [settled](#settled-1)
503
511
  * [object](#object)
504
512
  * [constructor](#constructor)
505
- * [Parameters](#parameters-121)
513
+ * [Parameters](#parameters-124)
506
514
  * [isAccessor](#isaccessor-1)
507
515
  * [isData](#isdata-1)
508
516
  * [isDescriptor](#isdescriptor)
509
517
  * [configurable](#configurable)
510
518
  * [configurable](#configurable-1)
511
- * [Parameters](#parameters-122)
519
+ * [Parameters](#parameters-125)
512
520
  * [enumerable](#enumerable)
513
521
  * [enumerable](#enumerable-1)
514
- * [Parameters](#parameters-123)
522
+ * [Parameters](#parameters-126)
515
523
  * [writable](#writable)
516
524
  * [writable](#writable-1)
517
- * [Parameters](#parameters-124)
525
+ * [Parameters](#parameters-127)
518
526
  * [value](#value-2)
519
527
  * [value](#value-3)
520
- * [Parameters](#parameters-125)
528
+ * [Parameters](#parameters-128)
521
529
  * [get](#get)
522
530
  * [get](#get-1)
523
- * [Parameters](#parameters-126)
531
+ * [Parameters](#parameters-129)
524
532
  * [boundGet](#boundget)
525
533
  * [set](#set)
526
534
  * [set](#set-1)
527
- * [Parameters](#parameters-127)
535
+ * [Parameters](#parameters-130)
528
536
  * [boundSet](#boundset)
529
537
  * [hasObject](#hasobject)
530
538
  * [object](#object-1)
531
539
  * [object](#object-2)
532
- * [Parameters](#parameters-128)
533
- * [for](#for-1)
534
- * [Parameters](#parameters-129)
540
+ * [Parameters](#parameters-131)
541
+ * [for](#for-2)
542
+ * [Parameters](#parameters-132)
535
543
  * [applyTo](#applyto)
536
- * [Parameters](#parameters-130)
544
+ * [Parameters](#parameters-133)
537
545
  * [toObject](#toobject)
538
- * [Parameters](#parameters-131)
546
+ * [Parameters](#parameters-134)
539
547
  * [toPrimitive](#toprimitive)
540
- * [Parameters](#parameters-132)
548
+ * [Parameters](#parameters-135)
541
549
  * [toStringTag](#tostringtag)
542
- * [for](#for-2)
543
- * [Parameters](#parameters-133)
550
+ * [for](#for-3)
551
+ * [Parameters](#parameters-136)
544
552
  * [getData](#getdata)
545
- * [Parameters](#parameters-134)
553
+ * [Parameters](#parameters-137)
546
554
  * [getAccessor](#getaccessor)
547
- * [Parameters](#parameters-135)
555
+ * [Parameters](#parameters-138)
548
556
  * [base](#base)
549
- * [Parameters](#parameters-136)
557
+ * [Parameters](#parameters-139)
550
558
  * [accessor](#accessor)
551
- * [Parameters](#parameters-137)
559
+ * [Parameters](#parameters-140)
552
560
  * [data](#data-2)
553
- * [Parameters](#parameters-138)
561
+ * [Parameters](#parameters-141)
554
562
  * [isDescriptor](#isdescriptor-1)
555
- * [Parameters](#parameters-139)
563
+ * [Parameters](#parameters-142)
556
564
  * [isData](#isdata-2)
557
- * [Parameters](#parameters-140)
565
+ * [Parameters](#parameters-143)
558
566
  * [isAccessor](#isaccessor-2)
559
- * [Parameters](#parameters-141)
567
+ * [Parameters](#parameters-144)
560
568
  * [flexible](#flexible)
561
569
  * [enigmatic](#enigmatic)
562
570
  * [intrinsic](#intrinsic)
@@ -565,14 +573,14 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
565
573
  * [ACCESSOR\_KEYS](#accessor_keys)
566
574
  * [DATA\_KEYS](#data_keys)
567
575
  * [Iterable](#iterable)
568
- * [Parameters](#parameters-142)
576
+ * [Parameters](#parameters-145)
569
577
  * [iterator](#iterator)
570
578
  * [asArray](#asarray)
571
579
  * [toStringTag](#tostringtag-1)
572
580
  * [isIterable](#isiterable)
573
- * [Parameters](#parameters-143)
581
+ * [Parameters](#parameters-146)
574
582
  * [Iterator](#iterator-1)
575
- * [Parameters](#parameters-144)
583
+ * [Parameters](#parameters-147)
576
584
  * [asArray](#asarray-1)
577
585
  * [iterable](#iterable-1)
578
586
  * [next](#next)
@@ -581,44 +589,44 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
581
589
  * [toStringTag](#tostringtag-2)
582
590
  * [mapEach](#mapeach)
583
591
  * [constructor](#constructor-1)
584
- * [Parameters](#parameters-145)
585
- * [Examples](#examples-123)
592
+ * [Parameters](#parameters-148)
593
+ * [Examples](#examples-125)
586
594
  * [parse](#parse)
587
- * [Parameters](#parameters-146)
595
+ * [Parameters](#parameters-149)
588
596
  * [validate](#validate)
589
- * [Parameters](#parameters-147)
597
+ * [Parameters](#parameters-150)
590
598
  * [tryParsers](#tryparsers)
591
- * [Parameters](#parameters-148)
592
- * [Examples](#examples-124)
599
+ * [Parameters](#parameters-151)
600
+ * [Examples](#examples-126)
593
601
  * [safeTryParsers](#safetryparsers)
594
- * [Parameters](#parameters-149)
595
- * [Examples](#examples-125)
602
+ * [Parameters](#parameters-152)
603
+ * [Examples](#examples-127)
596
604
  * [NoValidParsersFound](#novalidparsersfound)
597
- * [Examples](#examples-126)
605
+ * [Examples](#examples-128)
598
606
  * [ParametersMustBeArrayError](#parametersmustbearrayerror)
599
- * [Examples](#examples-127)
607
+ * [Examples](#examples-129)
600
608
  * [ParsersArrayMustContainParsersError](#parsersarraymustcontainparserserror)
601
- * [Examples](#examples-128)
609
+ * [Examples](#examples-130)
602
610
  * [toStringTag](#tostringtag-3)
603
- * [Examples](#examples-129)
611
+ * [Examples](#examples-131)
604
612
  * [hasInstance](#hasinstance)
605
- * [Parameters](#parameters-150)
606
- * [Examples](#examples-130)
613
+ * [Parameters](#parameters-153)
614
+ * [Examples](#examples-132)
607
615
  * [response](#response)
608
- * [Parameters](#parameters-151)
609
- * [Examples](#examples-131)
616
+ * [Parameters](#parameters-154)
617
+ * [Examples](#examples-133)
610
618
  * [ResponseType](#responsetype)
611
619
  * [Properties](#properties)
612
- * [Examples](#examples-132)
620
+ * [Examples](#examples-134)
613
621
  * [nameFromType](#namefromtype)
614
- * [Parameters](#parameters-152)
615
- * [Examples](#examples-133)
622
+ * [Parameters](#parameters-155)
623
+ * [Examples](#examples-135)
616
624
  * [typeNames](#typenames)
617
625
  * [Properties](#properties-1)
618
- * [Examples](#examples-134)
626
+ * [Examples](#examples-136)
619
627
  * [type](#type)
620
628
  * [Properties](#properties-2)
621
- * [Examples](#examples-135)
629
+ * [Examples](#examples-137)
622
630
  * [apply](#apply)
623
631
  * [construct](#construct)
624
632
  * [defineProperty](#defineproperty)
@@ -633,112 +641,112 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
633
641
  * [set](#set-2)
634
642
  * [setPrototypeOf](#setprototypeof)
635
643
  * [RefMap](#refmap)
636
- * [Parameters](#parameters-153)
644
+ * [Parameters](#parameters-156)
637
645
  * [objectifying](#objectifying)
638
- * [Parameters](#parameters-154)
646
+ * [Parameters](#parameters-157)
639
647
  * [asObject](#asobject)
640
648
  * [objectifyValues](#objectifyvalues)
641
649
  * [objectifyValues](#objectifyvalues-1)
642
- * [Parameters](#parameters-155)
650
+ * [Parameters](#parameters-158)
643
651
  * [get](#get-3)
644
- * [Parameters](#parameters-156)
652
+ * [Parameters](#parameters-159)
645
653
  * [set](#set-3)
646
- * [Parameters](#parameters-157)
654
+ * [Parameters](#parameters-160)
647
655
  * [setAll](#setall)
648
- * [Parameters](#parameters-158)
656
+ * [Parameters](#parameters-161)
649
657
  * [clean](#clean)
650
658
  * [entries](#entries-1)
651
- * [Parameters](#parameters-159)
659
+ * [Parameters](#parameters-162)
652
660
  * [forEach](#foreach)
653
- * [Parameters](#parameters-160)
661
+ * [Parameters](#parameters-163)
654
662
  * [values](#values-1)
655
663
  * [hasValue](#hasvalue)
656
- * [Parameters](#parameters-161)
664
+ * [Parameters](#parameters-164)
657
665
  * [filter](#filter)
658
- * [Parameters](#parameters-162)
666
+ * [Parameters](#parameters-165)
659
667
  * [find](#find-1)
660
- * [Parameters](#parameters-163)
668
+ * [Parameters](#parameters-166)
661
669
  * [map](#map-1)
662
- * [Parameters](#parameters-164)
670
+ * [Parameters](#parameters-167)
663
671
  * [iterator](#iterator-3)
664
672
  * [toStringTag](#tostringtag-4)
665
673
  * [isValidReference](#isvalidreference)
666
- * [Parameters](#parameters-165)
674
+ * [Parameters](#parameters-168)
667
675
  * [RefSet](#refset)
668
676
  * [objectifying](#objectifying-1)
669
- * [Parameters](#parameters-166)
677
+ * [Parameters](#parameters-169)
670
678
  * [objectifyValues](#objectifyvalues-2)
671
679
  * [objectifyValues](#objectifyvalues-3)
672
- * [Parameters](#parameters-167)
680
+ * [Parameters](#parameters-170)
673
681
  * [add](#add)
674
- * [Parameters](#parameters-168)
682
+ * [Parameters](#parameters-171)
675
683
  * [addAll](#addall)
676
- * [Parameters](#parameters-169)
684
+ * [Parameters](#parameters-172)
677
685
  * [clean](#clean-1)
678
686
  * [entries](#entries-2)
679
- * [Parameters](#parameters-170)
687
+ * [Parameters](#parameters-173)
680
688
  * [forEach](#foreach-1)
681
- * [Parameters](#parameters-171)
689
+ * [Parameters](#parameters-174)
682
690
  * [values](#values-2)
683
691
  * [keys](#keys-1)
684
692
  * [has](#has-1)
685
- * [Parameters](#parameters-172)
693
+ * [Parameters](#parameters-175)
686
694
  * [contains](#contains-2)
687
- * [Parameters](#parameters-173)
695
+ * [Parameters](#parameters-176)
688
696
  * [filter](#filter-1)
689
- * [Parameters](#parameters-174)
697
+ * [Parameters](#parameters-177)
690
698
  * [find](#find-2)
691
- * [Parameters](#parameters-175)
699
+ * [Parameters](#parameters-178)
692
700
  * [map](#map-2)
693
- * [Parameters](#parameters-176)
701
+ * [Parameters](#parameters-179)
694
702
  * [toStringTag](#tostringtag-5)
695
703
  * [Symkeys](#symkeys)
696
- * [Parameters](#parameters-177)
697
- * [Examples](#examples-136)
704
+ * [Parameters](#parameters-180)
705
+ * [Examples](#examples-138)
698
706
  * [add](#add-1)
699
- * [Parameters](#parameters-178)
700
- * [Examples](#examples-137)
707
+ * [Parameters](#parameters-181)
708
+ * [Examples](#examples-139)
701
709
  * [data](#data-3)
702
- * [Parameters](#parameters-179)
703
- * [Examples](#examples-138)
710
+ * [Parameters](#parameters-182)
711
+ * [Examples](#examples-140)
704
712
  * [deleteData](#deletedata)
705
- * [Parameters](#parameters-180)
706
- * [Examples](#examples-139)
713
+ * [Parameters](#parameters-183)
714
+ * [Examples](#examples-141)
707
715
  * [hasData](#hasdata)
708
- * [Parameters](#parameters-181)
709
- * [Examples](#examples-140)
716
+ * [Parameters](#parameters-184)
717
+ * [Examples](#examples-142)
710
718
  * [setData](#setdata)
711
- * [Parameters](#parameters-182)
712
- * [Examples](#examples-141)
719
+ * [Parameters](#parameters-185)
720
+ * [Examples](#examples-143)
713
721
  * [token](#token)
714
- * [Parameters](#parameters-183)
715
- * [Examples](#examples-142)
722
+ * [Parameters](#parameters-186)
723
+ * [Examples](#examples-144)
716
724
  * [separator](#separator)
717
- * [Examples](#examples-143)
725
+ * [Examples](#examples-145)
718
726
  * [symbols](#symbols)
719
- * [Examples](#examples-144)
727
+ * [Examples](#examples-146)
720
728
  * [calculateName](#calculatename)
721
- * [Parameters](#parameters-184)
722
- * [Examples](#examples-145)
729
+ * [Parameters](#parameters-187)
730
+ * [Examples](#examples-147)
723
731
  * [isSymkey](#issymkey)
724
- * [Parameters](#parameters-185)
725
- * [Examples](#examples-146)
732
+ * [Parameters](#parameters-188)
733
+ * [Examples](#examples-148)
726
734
  * [token](#token-1)
727
- * [Examples](#examples-147)
735
+ * [Examples](#examples-149)
728
736
  * [kDataKey](#kdatakey)
729
737
  * [kPrototype](#kprototype)
730
738
  * [kDomain](#kdomain)
731
- * [Examples](#examples-148)
739
+ * [Examples](#examples-150)
732
740
  * [kSeparator](#kseparator)
733
- * [Examples](#examples-149)
741
+ * [Examples](#examples-151)
734
742
  * [AsyncIterable](#asynciterable)
735
- * [Parameters](#parameters-186)
743
+ * [Parameters](#parameters-189)
736
744
  * [asyncIterator](#asynciterator)
737
745
  * [toStringTag](#tostringtag-6)
738
746
  * [isAsyncIterable](#isasynciterable)
739
- * [Parameters](#parameters-187)
747
+ * [Parameters](#parameters-190)
740
748
  * [AsyncIterator](#asynciterator-1)
741
- * [Parameters](#parameters-188)
749
+ * [Parameters](#parameters-191)
742
750
  * [asArray](#asarray-2)
743
751
  * [asyncIterable](#asynciterable-1)
744
752
  * [next](#next-1)
@@ -2111,6 +2119,7 @@ returns true. If no potential JSON object is found, the method returns false.
2111
2119
  #### Parameters
2112
2120
 
2113
2121
  * `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The string to check for potential JSON objects.
2122
+ * `detail` (optional, default `false`)
2114
2123
 
2115
2124
  #### Examples
2116
2125
 
@@ -4641,6 +4650,86 @@ console.log(forcedGreen); // Output: "rgba(58,255,76,0.50)"
4641
4650
 
4642
4651
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A random RGBA color code.
4643
4652
 
4653
+ #### sgr
4654
+
4655
+ Applies Select Graphic Rendition (SGR) parameters to a given message for
4656
+ styling in terminal environments. This function allows for the dynamic
4657
+ styling of text output using ANSI escape codes. It supports a variety of
4658
+ modes such as color, brightness, and text decorations like bold or underline.
4659
+
4660
+ ##### Parameters
4661
+
4662
+ * `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The message to be styled.
4663
+ * `useModes` **...[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A series of strings representing the desired
4664
+ styling modes. Modes can include colors (e.g., 'red', 'blue'), brightness
4665
+ ('bright'), foreground/background ('fg', 'bg'), and text decorations
4666
+ ('bold', 'underline'). Modes can be combined in a single string using
4667
+ commas or passed as separate arguments.Colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'Color Specifiers: 'fg' -> foreground | 'bg' -> background | 'bright' -> bright colorsModes: 'blink' or 'k' | 'conceal' or 'c' | 'italics' or 'i' | 'strike' or 's'
4668
+ 'bold' or 'b' | 'dim' or 'd' | 'negative' or 'n' | 'underline' or 'u'Examples:* `sgr('Hello', 'red')` applies red color to 'Hello'.
4669
+ * `sgr('World', 'green,bold')` applies green color and bold styling
4670
+ to 'World'.
4671
+ * `sgr('Example', 'bluebgbright')` applies bright blue
4672
+ background color.Short hand syntax is also allowed:* `sgr('hello', 'biu')` applies bold, italics and underline
4673
+ * `sgr('hello', 'bi,redfg')` applies bold, italics and red foregroundAs a bonus, there is a secret getter applied to the return string that
4674
+ allows you to invoke `sgr(...).show` to automatically log the output to
4675
+ `console.log`. This is done by wrapping the output string in `Object()`
4676
+ to make it a `String` instance and then adding the property descriptor.
4677
+ A custom `Symbol` is applied to make it evaluate in nodejs as though it
4678
+ were a normal string. To strip the extras, wrap the output in `String()`
4679
+
4680
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The message wrapped in ANSI escape codes corresponding
4681
+ to the specified modes. The returned string, when printed to a terminal,
4682
+ displays the styled message. Additional properties are attached to the
4683
+ result for utility purposes, such as 'show' for immediate console output.
4684
+
4685
+ #### wrap
4686
+
4687
+ Wraps an object's properties into a formatted string.
4688
+
4689
+ This method takes an object and a set of options to format the
4690
+ object's properties into a string. It allows customization of
4691
+ indentation, line endings, maximum line length, and more.
4692
+
4693
+ ##### Parameters
4694
+
4695
+ * `objectOrLines`  
4696
+ * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The formatting options. (optional, default `{}`)
4697
+
4698
+ * `options.indent` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The number of indentation
4699
+ characters to use. (optional, default `2`)
4700
+ * `options.indentCharacter` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The character to use
4701
+ for indentation. (optional, default `' '`)
4702
+ * `options.inspector` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The inspector to use for retrieving object properties. (optional, default `[Object,'getOwnPropertyNames']`)
4703
+ * `options.lineEnding` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The line ending character. (optional, default `'\n'`)
4704
+ * `options.maxLen` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The maximum line length. (optional, default `78`)
4705
+ * `options.perLine` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** A function to apply
4706
+ per line of output. (optional, default `undefined`)
4707
+ * `options.perLinePerProperty` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** A function
4708
+ to apply per property per line of output. (optional, default `undefined`)
4709
+ * `options.preProcess` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** A function to
4710
+ preprocess the object's properties. (optional, default `undefined`)
4711
+ * `options.preReturn` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** A function to apply
4712
+ to the final output before returning. (optional, default `undefined`)
4713
+ * `options.separator` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The separator to use
4714
+ between properties. (optional, default `', '`)
4715
+ * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The object to wrap. (optional, default `globalThis`)
4716
+
4717
+ ##### Examples
4718
+
4719
+ ```javascript
4720
+ const obj = { a: 1, b: 2, c: 3 }
4721
+ const wrapped = StringExtensions.wrap(obj, { maxLen: 20 })
4722
+ console.log(wrapped)
4723
+ // Output:
4724
+ // {
4725
+ // a: 1,
4726
+ // b: 2,
4727
+ // c: 3
4728
+ // }
4729
+ ```
4730
+
4731
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The formatted string representation of the object.
4732
+
4644
4733
  ### isString
4645
4734
 
4646
4735
  Determines if the current object is a string.
@@ -4756,35 +4845,6 @@ and retrieving the string tag of an object. These methods are useful for
4756
4845
  enhancing the capabilities of the standard `Symbol` class with additional
4757
4846
  utility functions.
4758
4847
 
4759
- #### withData
4760
-
4761
- Creates a new Symbol with the given name and optional data. If data
4762
- is provided, it will be stringified and appended to the symbol's
4763
- name. This method is useful for creating unique symbols that carry
4764
- additional metadata.
4765
-
4766
- ##### Parameters
4767
-
4768
- * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the symbol.
4769
- * `data` **any?** Optional data to be associated with the symbol.
4770
-
4771
- ##### Examples
4772
-
4773
- ```javascript
4774
- const symbolWithData = Symbol.withData('mySymbol', { foo: 'bar' })
4775
- console.log(symbolWithData.toString())
4776
- // Output: "Symbol(mySymbol {"foo":"bar"})"
4777
- ```
4778
-
4779
- ```javascript
4780
- const symbolWithoutData = Symbol.withData('mySymbol')
4781
- console.log(symbolWithoutData.toString())
4782
- // Output: "Symbol(mySymbol)"
4783
- ```
4784
-
4785
- Returns **[symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol)** A new symbol created with Symbol.for(), using the
4786
- provided name and stringified data (if provided).
4787
-
4788
4848
  #### isSymbol
4789
4849
 
4790
4850
  The `isSymbol` method does exactly what one would it expect. It returns
@@ -4868,6 +4928,35 @@ kOriginal.data.original = Object.prototype // ...and...
4868
4928
  kOriginal.data = [Object.prototype, Array.prototype] // ...both work
4869
4929
  ```
4870
4930
 
4931
+ #### withData
4932
+
4933
+ Creates a new Symbol with the given name and optional data. If data
4934
+ is provided, it will be stringified and appended to the symbol's
4935
+ name. This method is useful for creating unique symbols that carry
4936
+ additional metadata.
4937
+
4938
+ ##### Parameters
4939
+
4940
+ * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the symbol.
4941
+ * `data` **any?** Optional data to be associated with the symbol.
4942
+
4943
+ ##### Examples
4944
+
4945
+ ```javascript
4946
+ const symbolWithData = Symbol.withData('mySymbol', { foo: 'bar' })
4947
+ console.log(symbolWithData.toString())
4948
+ // Output: "Symbol(mySymbol {"foo":"bar"})"
4949
+ ```
4950
+
4951
+ ```javascript
4952
+ const symbolWithoutData = Symbol.withData('mySymbol')
4953
+ console.log(symbolWithoutData.toString())
4954
+ // Output: "Symbol(mySymbol)"
4955
+ ```
4956
+
4957
+ Returns **[symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol)** A new symbol created with Symbol.for(), using the
4958
+ provided name and stringified data (if provided).
4959
+
4871
4960
  ### instance
4872
4961
 
4873
4962
  Returns an object representation of the symbol instance.
@@ -5000,6 +5089,38 @@ console.log(sym.mightHaveEmbeddedJSON) // Output: false
5000
5089
  Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Returns true if the symbol might have embedded
5001
5090
  JSON, false otherwise.
5002
5091
 
5092
+ ### for
5093
+
5094
+ Custom inspect method for Node.js util.inspect.
5095
+
5096
+ NOTE: this will only apply if looking at an instance of Symbol,
5097
+ sadly; {@see SymbolPrototypeExtensions.instance}
5098
+
5099
+ This method is used by Node.js util.inspect to provide a custom
5100
+ representation of the symbol when inspected. It checks if the
5101
+ symbol's description might contain JSON data and if so, it
5102
+ truncates the JSON data in the description to a maximum of 30
5103
+ characters and formats the output with colors using the `sgr`
5104
+ function from the `String` object.
5105
+
5106
+ #### Parameters
5107
+
5108
+ * `depth` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current depth of the recursive
5109
+ inspection.
5110
+ * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The options object passed to
5111
+ util.inspect.
5112
+ * `inspect` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** The original util.inspect function.
5113
+
5114
+ #### Examples
5115
+
5116
+ ```javascript
5117
+ const sym = Symbol.for('fun {"name":"John Doe"}')
5118
+ console.log(util.inspect(sym))
5119
+ // Output: Symbol.for(fun {"name":"John ...hn Doe"})
5120
+ ```
5121
+
5122
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The formatted representation of the symbol.
5123
+
5003
5124
  ### Deferred
5004
5125
 
5005
5126
  **Extends Promise**