@nejs/basic-extensions 1.5.0 → 1.6.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/src/descriptor.js CHANGED
@@ -274,16 +274,16 @@ class Descriptor {
274
274
  }
275
275
 
276
276
  /**
277
- * The function `getData` retrieves the value of a property from an object if it
278
- * exists and is a data property.
277
+ * The function `getData` retrieves the value of a property from an object
278
+ * if it exists and is a data property.
279
279
  *
280
280
  * @param object - The "object" parameter is the object from which we want to
281
281
  * retrieve data.
282
282
  * @param property - The `property` parameter is the name of the property that
283
283
  * you want to retrieve the data from.
284
- * @returns either the value of the specified property if it exists and is a data
285
- * property, or undefined if the property does not exist or is not a data
286
- * property.
284
+ * @returns either the value of the specified property if it exists and is
285
+ * a data property, or undefined if the property does not exist or is not
286
+ * a data property.
287
287
  */
288
288
  static getData(object, property) {
289
289
  if (!isObject(object) || !isString(property)) {
@@ -312,10 +312,10 @@ class Descriptor {
312
312
  * which we want to get the accessor.
313
313
  * @returns an object that contains the getter and setter functions for the
314
314
  * specified property of the given object. If the property is an accessor
315
- * property (defined with a getter and/or setter), the returned object will also
316
- * have additional properties such as "accessor" and "descriptor". If the
317
- * property is not found or is not an accessor property, the function returns
318
- * undefined.
315
+ * property (defined with a getter and/or setter), the returned object will
316
+ * also have additional properties such as "accessor" and "descriptor". If
317
+ * the property is not found or is not an accessor property, the function
318
+ * returns undefined.
319
319
  */
320
320
  static getAccessor(object, property) {
321
321
  if (!isObject(object))
@@ -361,14 +361,14 @@ class Descriptor {
361
361
  *
362
362
  * @param [enumerable=false] - A boolean value indicating whether the property
363
363
  * can be enumerated (listed) when iterating over the object's properties.
364
- * @param [configurable=false] - The `configurable` parameter determines whether
365
- * the property can be deleted or its attributes can be modified. If
366
- * `configurable` is set to `true`, the property can be deleted and its
367
- * attributes can be changed. If `configurable` is set to `false`, the property
368
- * cannot be deleted and
364
+ * @param [configurable=false] - The `configurable` parameter determines
365
+ * whether the property can be deleted or its attributes can be modified.
366
+ * If `configurable` is set to `true`, the property can be deleted and its
367
+ * attributes can be changed. If `configurable` is set to `false`, the
368
+ * property cannot be deleted and
369
369
  * @returns An object with the properties `enumerable` and `configurable` is
370
- * being returned. The values of these properties are determined by the arguments
371
- * passed to the `base` function.
370
+ * being returned. The values of these properties are determined by the
371
+ * arguments passed to the `base` function.
372
372
  */
373
373
  static base(enumerable = false, configurable = false) {
374
374
  return {
@@ -384,9 +384,9 @@ class Descriptor {
384
384
  *
385
385
  * @param getter - The getter parameter is a function that will be used as the
386
386
  * getter for the property. It will be called when the property is accessed.
387
- * @param setter - The `setter` parameter is a function that will be used as the
388
- * setter for the property. It will be called whenever the property is assigned a
389
- * new value.
387
+ * @param setter - The `setter` parameter is a function that will be used as
388
+ * the setter for the property. It will be called whenever the property is
389
+ * assigned a new value.
390
390
  * @param [] - - `getter`: A function that will be used as the getter for the
391
391
  * property.
392
392
  * @returns an object with properties "get", "set", "enumerable", and
@@ -406,13 +406,15 @@ class Descriptor {
406
406
  }
407
407
 
408
408
  /**
409
- * The function "newData" creates a new data object with customizable properties.
409
+ * The function "newData" creates a new data object with customizable
410
+ * properties.
410
411
  *
411
- * @param value - The value parameter represents the value that will be assigned
412
- * to the property.
413
- * @param [writable=true] - The `writable` parameter determines whether the value
414
- * of the property can be changed. If `writable` is set to `true`, the value can
415
- * be changed. If `writable` is set to `false`, the value cannot be changed.
412
+ * @param value - The value parameter represents the value that will be
413
+ * assigned to the property.
414
+ * @param [writable=true] - The `writable` parameter determines whether the
415
+ * value of the property can be changed. If `writable` is set to `true`, the
416
+ * value can be changed. If `writable` is set to `false`, the value cannot be
417
+ * changed.
416
418
  * @param [] - - `value`: The value to be assigned to the property.
417
419
  * @returns an object with properties `value`, `enumerable`, `writable`, and
418
420
  * `configurable`.
@@ -431,10 +433,11 @@ class Descriptor {
431
433
  }
432
434
 
433
435
  /**
434
- * The function checks if an object is a valid object descriptor in JavaScript.
436
+ * The function checks if an object is a valid object descriptor in
437
+ * JavaScript.
435
438
  *
436
- * @param object - The `object` parameter is the object that we want to check if
437
- * it is a descriptor.
439
+ * @param object - The `object` parameter is the object that we want to
440
+ * check if it is a descriptor.
438
441
  * @returns a boolean value.
439
442
  */
440
443
  static isDescriptor(object) {
@@ -450,12 +453,13 @@ class Descriptor {
450
453
  /**
451
454
  * The function checks if a given property or descriptor is a data property.
452
455
  *
453
- * @param descriptor_orProp - The `descriptor_orProp` parameter can be either a
454
- * descriptor or a property name.
455
- * @param object - The `object` parameter is the object that you want to check
456
- * for data properties.
457
- * @returns a boolean value. It returns `true` if the `descriptor` object has any
458
- * keys that match the `DATA_KEYS` array, otherwise it returns `false`.
456
+ * @param descriptor_orProp - The `descriptor_orProp` parameter can be
457
+ * either a descriptor or a property name.
458
+ * @param object - The `object` parameter is the object that you want to
459
+ * check for data properties.
460
+ * @returns a boolean value. It returns `true` if the `descriptor` object
461
+ * has any keys that match the `DATA_KEYS` array, otherwise it returns
462
+ * `false`.
459
463
  */
460
464
  static isData(object_orProp, property) {
461
465
  const needsDescriptor = (
@@ -482,15 +486,15 @@ class Descriptor {
482
486
  }
483
487
 
484
488
  /**
485
- * The function checks if a given property descriptor or property of an object is
486
- * an accessor.
489
+ * The function checks if a given property descriptor or property of an
490
+ * object is an accessor.
487
491
  *
488
492
  * @param object_orProp - The `descriptor_orProp` parameter can be either a
489
493
  * descriptor object or a property name.
490
- * @param property - The `object` parameter is the object that you want to check
491
- * for accessor properties.
492
- * @returns a boolean value. It returns true if the descriptor or property passed
493
- * as an argument is an accessor descriptor, and false otherwise.
494
+ * @param property - The `object` parameter is the object that you want to
495
+ * check for accessor properties.
496
+ * @returns a boolean value. It returns true if the descriptor or property
497
+ * passed as an argument is an accessor descriptor, and false otherwise.
494
498
  */
495
499
  static isAccessor(object_orProp, property) {
496
500
  const needsDescriptor = (
@@ -517,27 +521,30 @@ class Descriptor {
517
521
  }
518
522
 
519
523
  /**
520
- * A base descriptor (new for each read) that is both enumerable and configurable
524
+ * A base descriptor (new for each read) that is both enumerable and
525
+ * configurable
521
526
  *
522
- * @returns The method `flexible` is returning the result of calling the `base`
523
- * method with the arguments `true` and `true`.
527
+ * @returns The method `flexible` is returning the result of calling the
528
+ * `base` method with the arguments `true` and `true`.
524
529
  */
525
530
  static get flexible() {
526
531
  return this.base(true, true)
527
532
  }
528
533
 
529
534
  /**
530
- * A base descriptor (new for each read) that is not enumerable but is configurable
535
+ * A base descriptor (new for each read) that is not enumerable but is
536
+ * configurable
531
537
  *
532
- * @returns The method `enigmatic` is returning the result of calling the `base`
533
- * method with the arguments `false` and `true`.
538
+ * @returns The method `enigmatic` is returning the result of calling
539
+ * the `base` method with the arguments `false` and `true`.
534
540
  */
535
541
  static get enigmatic() {
536
542
  return this.base(false, true)
537
543
  }
538
544
 
539
545
  /**
540
- * A base descriptor (new for each read) that is neither enumerable nor configurable
546
+ * A base descriptor (new for each read) that is neither enumerable
547
+ * nor configurable
541
548
  *
542
549
  * @returns The code is returning the result of calling the `base` method with
543
550
  * the arguments `false` and `false`.
@@ -549,8 +556,8 @@ class Descriptor {
549
556
  /**
550
557
  * A base descriptor (new for each read) that enumerable but not configurable
551
558
  *
552
- * @returns The method is returning the result of calling the `base` method with
553
- * the arguments `true` and `false`.
559
+ * @returns The method is returning the result of calling the `base`
560
+ * method with the arguments `true` and `false`.
554
561
  */
555
562
  static get transparent() {
556
563
  return this.base(true, false)
@@ -1,45 +1,51 @@
1
1
  import { Patch } from '@nejs/extension'
2
2
 
3
3
  /**
4
- * The `FunctionExtensions` class is a patch applied to the built-in JavaScript `Function`
5
- * constructor. It extends `Function` with additional utility methods for determining the
6
- * specific type or nature of function-like objects. These methods allow developers to
7
- * distinguish between classes, regular functions, async functions, and arrow functions
8
- * in a more intuitive and straightforward manner. This class is part of the `@nejs/extension`
9
- * library and enhances the capabilities of function handling and introspection in JavaScript.
4
+ * The `FunctionExtensions` class is a patch applied to the built-in JavaScript
5
+ * `Function` constructor. It extends `Function` with additional utility methods
6
+ * for determining the specific type or nature of function-like objects. These
7
+ * methods allow developers to distinguish between classes, regular functions,
8
+ * async functions, and arrow functions in a more intuitive and straightforward
9
+ * manner. This class is part of the `@nejs/extension` library and enhances the
10
+ * capabilities of function handling and introspection in JavaScript.
10
11
  */
11
12
  export const FunctionExtensions = new Patch(Function, {
12
13
  /**
13
- * Determines if a given value is a class. It checks if the value is an instance of
14
- * `Function` and if its string representation includes the keyword 'class'. This method
15
- * is useful for distinguishing classes from other function types in JavaScript.
14
+ * Determines if a given value is a class. It checks if the value is an
15
+ * instance of `Function` and if its string representation includes the
16
+ * keyword 'class'. This method is useful for distinguishing classes from
17
+ * other function types in JavaScript.
16
18
  *
17
19
  * @param {*} value - The value to be checked.
18
- * @returns {boolean} Returns `true` if the value is a class, otherwise `false`.
20
+ * @returns {boolean} Returns `true` if the value is a class, otherwise
21
+ * `false`.
19
22
  */
20
23
  isClass(value) {
21
24
  return value instanceof Function && !!/^class\s/.exec(String(value))
22
25
  },
23
26
 
24
27
  /**
25
- * Checks if a given value is a regular function. This method verifies if the value is
26
- * an instance of `Function`, which includes regular functions, classes, and async
27
- * functions but excludes arrow functions.
28
+ * Checks if a given value is a regular function. This method verifies if
29
+ * the value is an instance of `Function`, which includes regular functions,
30
+ * classes, and async functions but excludes arrow functions.
28
31
  *
29
32
  * @param {*} value - The value to be checked.
30
- * @returns {boolean} Returns `true` if the value is a regular function, otherwise `false`.
33
+ * @returns {boolean} Returns `true` if the value is a regular function,
34
+ * otherwise `false`.
31
35
  */
32
36
  isFunction(value) {
33
37
  return value instanceof Function;
34
38
  },
35
39
 
36
40
  /**
37
- * Determines if a given value is an asynchronous function. It checks if the value is an
38
- * instance of `Function` and if its string representation includes the keyword 'Async'.
39
- * This method is particularly useful for identifying async functions.
41
+ * Determines if a given value is an asynchronous function. It checks if the
42
+ * value is an instance of `Function` and if its string representation
43
+ * includes the keyword 'Async'. This method is particularly useful for
44
+ * identifying async functions.
40
45
  *
41
46
  * @param {*} value - The value to be checked.
42
- * @returns {boolean} Returns `true` if the value is an async function, otherwise `false`.
47
+ * @returns {boolean} Returns `true` if the value is an async function,
48
+ * otherwise `false`.
43
49
  */
44
50
  isAsync(value) {
45
51
  const stringTag = /(\w+)]/g.exec(Object.prototype.toString.call(value))[1]
@@ -50,12 +56,14 @@ export const FunctionExtensions = new Patch(Function, {
50
56
  },
51
57
 
52
58
  /**
53
- * Checks if a given value is an arrow function. It verifies if the value is an instance
54
- * of `Function`, if its string representation includes the '=>' symbol, and if it lacks
55
- * a prototype, which is a characteristic of arrow functions in JavaScript.
59
+ * Checks if a given value is an arrow function. It verifies if the value is
60
+ * an instance of `Function`, if its string representation includes the '=>'
61
+ * symbol, and if it lacks a prototype, which is a characteristic of arrow
62
+ * functions in JavaScript.
56
63
  *
57
64
  * @param {*} value - The value to be checked.
58
- * @returns {boolean} Returns `true` if the value is an arrow function, otherwise `false`.
65
+ * @returns {boolean} Returns `true` if the value is an arrow function,
66
+ * otherwise `false`.
59
67
  */
60
68
  isBigArrow(value) {
61
69
  return (
@@ -67,16 +75,17 @@ export const FunctionExtensions = new Patch(Function, {
67
75
  },
68
76
 
69
77
  /**
70
- * Determines if a given value is a bound function. Bound functions are created using
71
- * the `Function.prototype.bind` method, which allows setting the `this` value at the
72
- * time of binding. This method checks if the value is an instance of `Function`, if
73
- * its string representation starts with 'bound', and if it lacks a `prototype`
74
- * property. These characteristics are indicative of bound functions in JavaScript.
78
+ * Determines if a given value is a bound function. Bound functions are
79
+ * created using the `Function.prototype.bind` method, which allows setting
80
+ * the `this` value at the time of binding. This method checks if the value
81
+ * is an instance of `Function`, if its string representation starts with
82
+ * 'bound', and if it lacks a `prototype` property. These characteristics
83
+ * are indicative of bound functions in JavaScript.
75
84
  *
76
85
  * @param {*} value - The value to be checked, typically a function.
77
- * @returns {boolean} Returns `true` if the value is a bound function, otherwise
78
- * `false`. Bound functions have a specific format in their string representation
79
- * and do not have their own `prototype` property.
86
+ * @returns {boolean} Returns `true` if the value is a bound function,
87
+ * otherwise `false`. Bound functions have a specific format in their
88
+ * string representation and do not have their own `prototype` property.
80
89
  */
81
90
  isBound(value) {
82
91
  return (
@@ -9,6 +9,14 @@ import { Patch } from '@nejs/extension';
9
9
  * utility functions.
10
10
  */
11
11
  export const ObjectExtensions = new Patch(Object, {
12
+ /**
13
+ * Checks to see if the supplied `value` is both an object, and has the
14
+ * appropriate symbol defined.
15
+ *
16
+ * @param {any} value the value to determine if it contains a defined
17
+ * `Symbol.toStringTag` defined.
18
+ * @returns true if the symbol is defined, false otherwise
19
+ */
12
20
  hasStringTag(value) {
13
21
  return Object.isObject(value) && Reflect.has(value, Symbol.toStringTag)
14
22
  },
@@ -1,2 +0,0 @@
1
- var nejsBasicExtensions=(()=>{var D=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var H=(r,t)=>{for(var e in t)D(r,e,{get:t[e],enumerable:!0})},J=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of U(t))!W.call(r,n)&&n!==e&&D(r,n,{get:()=>t[n],enumerable:!(s=B(t,n))||s.enumerable});return r};var L=r=>J(D({},"__esModule",{value:!0}),r);var rt={};H(rt,{ArrayPrototypeExtensions:()=>I,AsyncIterableExtensions:()=>k,AsyncIteratorExtensions:()=>F,DescriptorExtensions:()=>x,FunctionExtensions:()=>y,GlobalFunctionsAndProps:()=>A,IterableExtensions:()=>C,IteratorExtensions:()=>V,ObjectExtensions:()=>p,RefSetExtensions:()=>$,ReflectExtensions:()=>b,StringExtensions:()=>S,SymbolExtensions:()=>j,all:()=>et,disableAll:()=>tt,disableNetNew:()=>M,enableAll:()=>_,enableNetNew:()=>G});var q=r=>/(\w+)]/.exec(Object.prototype.toString.call(r))[1],d=class extends Error{constructor(t,e){super(`${q(t)} disallows tampering with ${e}.`),Object.assign(this,{owner:t,key:e})}get[Symbol.toStringTag](){return this.constructor.name}};var z=r=>/(\w+)]/.exec(Object.prototype.toString.call(r))[1],m=class extends Error{constructor(t,e){super(`${z(t)} does not have a property named '${e}'.`),Object.assign(this,{owner:t,key:e})}get[Symbol.toStringTag](){return this.constructor.name}};var g=class{constructor(t,e=!1){this.started=!1,this.preventRevert=e,this.patch=t,this.patchName=t.owner?.name??t.owner?.constructor?.name??/(\w+)]/.exec(Object.prototype.toString.call(t.owner))[1],this.state={needsApplication:!1,needsReversion:!1}}start(){return this.started||(this.state.needsApplication=!this.patch.applied,this.state.needsReversion=this.patch.applied,this.started=!0,this.state.needsApplication&&this.patch.apply()),this}stop(){return this.started&&((this.preventRevert||this.patch.applied)&&this.patch.revert(),this.state.needsApplication=!1,this.state.needsReversion=!1,this.started=!1),this}get[Symbol.toStringTag](){return`${this.constructor.name}:${this.patchName}`}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){let n=this[Symbol.toStringTag],i=`(started: ${this.started} needed: ${this.state.needsApplication})`;return s(`${n} ${i}`,{...e,depth:t})}};var c=class r{constructor(t,e,s={}){Object.assign(this,{owner:t,options:s,applied:!1}),this.patchConflicts={},this.patchEntries={},this.patchesOwner=e,Reflect.ownKeys(e).forEach(n=>{this.patchEntries[n]=new r.#t(n,this.patchesOwner),Reflect.has(this.owner,n)&&(this.patchConflicts[n]=new r.#t(n,this.owner))}),r.patches.has(t)||r.patches.set(t,[]),r.patches.get(t).push(this)}get patches(){return Reflect.ownKeys(this.patchEntries).map(t=>[t,this.patchEntries[t]])}get conflicts(){return Reflect.ownKeys(this.patchConflicts).map(t=>[t,this.patchConflicts[t]])}apply(){this.applied||(this.patches.forEach(([,t])=>{Object.defineProperty(this.owner,t.key,t.descriptor)}),this.applied=!0)}createToggle(t=!1){return new g(this,t)}revert(){this.applied&&(this.patches.forEach(([,t])=>{delete this.owner[t.key]}),this.conflicts.forEach(([,t])=>{Object.defineProperty(this.owner,t.key,t.descriptor)}),this.applied=!1)}release(){let t=r.patches.get(this.owner);t.splice(t.find(e=>e===this),1)}owner=null;options=null;static patches=new Map;static enableFor(t){if(r.patches.has(t))for(let e of r.patches.get(t))e.apply()}static disableFor(t){if(r.patches.has(t))for(let e of r.patches.get(t))e.revert()}static#t=class{constructor(t,e=globalThis){Object.assign(this,{key:t,descriptor:Object.getOwnPropertyDescriptor(e,t),owner:e})}get computed(){return this.isAccessor?this.descriptor.get.bind(this.owner).call():this.descriptor.value}get isData(){return Reflect.has(this.descriptor,"value")}get isAccessor(){return Reflect.has(this.descriptor,"get")}get isReadOnly(){return Reflect.has(this.descriptor,"configurable")&&!this.descriptor.configurable||Reflect.has(this.descriptor,"writable")&&!this.descriptor.writable}get[Symbol.toStringTag](){return this.constructor.name}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){return`PatchEntry<${this.key}, ${this.isData?"Data":"Accessor"}${this.isReadOnly?" [ReadOnly]":""}>`}}};var f=class r extends c{constructor(t,e,s=globalThis,n={}){let{key:i,extension:o,valid:a}=r.determineInput(t);if(o=e||o,!a)throw new m(s,i);let l=Object.getOwnPropertyDescriptor(s,i);if(l&&(Reflect.has(l,"writable")&&!l.writable||Reflect.has(l,"configurable")&&!l.configurable))throw new d(s,i);super(s,{[i]:o},n),this.key=i}static determineInput(t){let e={key:null,extension:null,valid:!1};return t instanceof Function?e={key:t.name,extension:t,valid:!0}:(typeof t=="string"||t instanceof String)&&(e={key:t,extension:null,valid:!0}),e}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){return`Extension<${this.key}>`}get[Symbol.toStringTag](){return this.constructor.name}};var y=new c(Function,{isClass(r){return r instanceof Function&&!!/^class\s/.exec(String(r))},isFunction(r){return r instanceof Function},isAsync(r){let t=/(\w+)]/g.exec(Object.prototype.toString.call(r))[1];return r instanceof Function&&t.includes("Async")},isBigArrow(r){return r instanceof Function&&String(r).includes("=>")&&!String(r).startsWith("bound")&&!Reflect.has(r,"prototype")},isBound(r){return r instanceof Function&&String(r).startsWith("bound")&&!Reflect.has(r,"prototype")}});var p=new c(Object,{hasStringTag(r){return Object.isObject(r)&&Reflect.has(r,Symbol.toStringTag)},getStringTag(r){return Object.hasStringTag(r)?r[Symbol.toStringTag]:r&&typeof r=="function"?r.name:/\s(.+)]/.exec(Object.prototype.toString.call(r))[1]},getType(r,t=globalThis){let e=Object.getStringTag(r);switch(e){case"Null":return null;case"Undefined":return;default:return t[e]}},isObject(r){return r&&(r instanceof Object||typeof r=="object")},isPrimitive(r){if(r===null)return!0;switch(typeof r){case"string":case"number":case"bigint":case"boolean":case"undefined":case"symbol":return!0;default:return!1}},isValidKey(r){return typeof r=="string"||typeof r=="symbol"},stripTo(r,t,e=!0){let s={};if(!Array.isArray(t))return s;for(let n of t)if(Reflect.has(r,n)){let i=Object.getOwnPropertyDescriptor(r,n);(Reflect.has(i,"get")||Reflect.has(i,"set"))&&e&&(i.get=i?.get?.bind(r),i.set=i?.set?.bind(r)),Object.defineProperty(s,i)}return s}});var b=new c(Reflect,{hasAll(r,...t){return Object.isObject(r)&&t.flat(1/0).map(e=>Reflect.has(r,e)).every(e=>e)},ownDescriptors(r){let t={},e=()=>e.doIt?p.revert():"";if(e.doIt=!1,Object.isObject||(e.doIt=!0,p.apply()),!Object.isObject(r))return e(),{};let s=Reflect.ownKeys(r);for(let n of s)t[n]=Object.getOwnPropertyDescriptor(n);return e(),t},hasSome(r,...t){return Object.isObject(r)&&t.flat(1/0).map(e=>Reflect.has(r,e)).some(e=>e)},entries(r){return!r||typeof r!="object"?[]:Reflect.ownKeys(r).map(t=>[t,Object.getOwnPropertyDescriptor(r,t)])},values(r){return Reflect.entries.map(([,t])=>t)}});var S=new c(String,{isString(r){return r&&(typeof r=="string"||r instanceof String)?r.length>0:!1}});var j=new c(Symbol,{isSymbol(r){return r&&typeof r=="symbol"},isRegistered(r,t=!1){if(!Symbol.isSymbol(r)){if(t)throw new TypeError("allowOnlySymbols specified; value is not a symbol");return!1}return Symbol.keyFor(r)!==void 0},isNonRegistered(r,t=!1){return!Symbol.isRegistered(r,t)}});var I=new c(Array.prototype,{contains(r){return!!this.find(t=>t===r)},findEntry(r){let t=this.entries(),e=1;for(let s of t)if(r(s[e]))return s},get first(){return this[0]},get last(){return this[this.length-1]}});var w=p.patchEntries?.isObject?.computed,N=p.patchEntries?.isValidKey?.computed,Q=S.patchEntries?.isString?.computed,E=b.patchEntries?.hasSome?.computed,v=class r{#t=r.enigmatic;constructor(t,e){if(this.#t=t,w(t)&&N(e)&&(this.#t=Object.getOwnPropertyDescriptor(t,e)),!this.isDescriptor)throw new Error("Not a valid descriptor:",this.#t)}get isAccessor(){return r.isAccessor(this.#t)}get isData(){return r.isData(this.#t)}get isDescriptor(){return r.isDescriptor(this.#t)}get configurable(){return!!this.#t?.configurable}set configurable(t){(this.#t||{}).configurable=!!t}get enumerable(){return this.#t?.enumerable}set enumerable(t){(this.#t||{}).enumerable=t}get writable(){return this.#t?.writable}set writable(t){(this.#t||{}).writable=t}get value(){return this.#t?.value}set value(t){(this.#t||{}).value=t}get get(){return this.#t?.get}set get(t){(this.#t||{}).get=t}get set(){return this.#t?.writable}set set(t){(this.#t||{}).set=t}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){return`Descriptor${this.isAccessor?" (Accessor)":this.isData?" (Data)":""} ${s(this.#t,{...e,depth:t})}`}static for(t,e){return!w(t)&&!N(e)?null:Object.getOwnPropertyDescriptor(t,e)}applyTo(t,e){if(!w(t)||!N(e))throw new Error("Cannot apply descriptor to non-object or invalid key");return Object.defineProperty(t,e,this.#t)}[Symbol.toPrimitive](t){switch(t){case"string":if(this.isAccessor){let e=Reflect.has(this.#t,"get")?"getter":"",s=Reflect.has(this.#t,"set")?"setter":"";return`Accessor (${e}${e&&s?", ":""}${s})`}else if(this.isData){let e=Reflect.has(this.#t,"value")?"value":"",s=Reflect.has(this.#t,"writable")?"writable":"";return`Data (${e}${e&&s?", ":""}${s})`}break;case"number":return NaN;default:return this.#t}}get[Symbol.toStringTag](){return this.constructor.name}static getData(t,e){if(!w(t)||!Q(e))return null;let s=r.all(t);if(s.has(e)){let n=s.get(e);if(r.isData(n))return n.value}}static getAccessor(t,e){if(!w(t))return null;let[s,n,i]=[0,1,2],o=[void 0,void 0,void 0],a=this.all(t),l=r.isDescriptor(t);if(a.has(e)||l){let u=l?t:a.get(e);if(r.isAccessor(u))return o[i]=a.object(e),o[s]=u?.get,o[n]=u?.set,Object.assign(o,{get(){this[s].bind(this[i])()},set(h){this[n].bind(this[i])(h)},get accessor(){return!0},get descriptor(){return u},get boundDescriptor(){return{...u,get:u.get?.bind(t),set:u.set?.bind(t)}}}),o}}static base(t=!1,e=!1){return{enumerable:t,configurable:e}}static accessor(t,e,{enumerable:s,configurable:n}=r.base()){return{get:t,set:e,enumerable:s,configurable:n}}static data(t,e=!0,{enumerable:s,configurable:n}=r.base()){return{value:t,enumerable:s,writable:e,configurable:n}}static isDescriptor(t){let e=[...r.SHARED_KEYS,...r.ACCESSOR_KEYS,...r.DATA_KEYS];return E(t,e)}static isData(t,e){let n=(typeof t=="object"||t instanceof Object)&&e instanceof String?r.for(t,e):t,{ACCESSOR_KEYS:i,DATA_KEYS:o}=this,a=!1;return E(n,i)?a=!1:E(n,o)&&(a=!0),a}static isAccessor(t,e){let n=t&&e&&(typeof t=="object"||t instanceof Object)&&(e instanceof String||typeof e=="symbol")?r.for(t,e):t,{ACCESSOR_KEYS:i,DATA_KEYS:o}=this,a=!1;return E(n,o)?a=!1:E(n,i)&&(a=!0),a}static get flexible(){return this.base(!0,!0)}static get enigmatic(){return this.base(!1,!0)}static get intrinsic(){return this.base(!1,!1)}static get transparent(){return this.base(!0,!1)}static get SHARED_KEYS(){return["configurable","enumerable"]}static get ACCESSOR_KEYS(){return["get","set"]}static get DATA_KEYS(){return["value","writable"]}},x=new f(v);var{isClass:X,isFunction:O}=y.patchEntries.isClass.computed,Z=Symbol.for("nodejs.util.inspect.custom"),A=new c(globalThis,{maskAs(r,t,e){let{prototype:s,toPrimitive:n}=GenericMask({...e,prototype:t}),i={configurable:!0,enumerable:!1},o=O(s)?s.prototype:s,a=X(s)?s:o?.constructor;return!a&&!o?null:(Object.setPrototypeOf(r,o),Object.defineProperties(r,{valueOf:{value(){return String(n("default",r))},...i},[Symbol.toPrimitive]:{value(l){return n(l,r)},...i},[Symbol.toStringTag]:{value:a.name,...i},[Symbol.species]:{get(){return a},...i},[Z]:{...i,value(l,u,h){return h(this[Symbol.toPrimitive](),{...u,depth:l})}}}),r)},maskAsString(r,t,e){return r&&Reflect.has(r,t)?maskAs(r,StringMask(t??"value",e)):null},maskAsNumber(r,t,e){return r&&Reflect.has(r,t)?maskAs(r,NumberMask(t??"value",e)):null},GenericMask({prototype:r,targetKey:t="value",toPrimitive:e}){let s={targetKey:t,toPrimitive:e,prototype:r};return O(e)||(s.toPrimitive=(n,i)=>{let o=i[t],a=typeof o=="number"&&Number.isFinite(o)||typeof o=="string"&&!isNaN(parseFloat(o))&&isFinite(o);switch(n){case"string":return a?String(o):o??String(i);case"number":return a?Number(o):NaN;case"default":default:return a?Number(o):o}}),s},StringMask(r,t){let e={targetKey:r,toPrimitive:t,prototype:String.prototype};return O(t)||(e.toPrimitive=function(n,i){switch(n){case"default":return i[r];case"number":return parseInt(i[r],36);case"string":return String(i[r]);default:return i}}),e},NumberMask(r,t){let e={targetKey:r,toPrimitive:t,prototype:Number.prototype};return O(t)||(e.toPrimitive=function(n,i){switch(n){case"default":return i[r];case"number":return Number(i[r]);case"string":return String(i[r]);default:return i}}),e}});var P=class r extends Set{#t=!1;objectifying(t=!0){return this.objectifyValues=t,this}get objectifyValues(){return this.#t}set objectifyValues(t){this.#t=!!t}add(t){if(this.#t&&(typeof t=="number"||typeof t=="string"||typeof t=="boolean"||typeof t=="bigint")&&(t=Object(t)),typeof t=="symbol"&&Symbol.keyFor(t)!==void 0)throw new TypeError("RefSet cannot accept registered symbols as values");if(typeof t!="object"&&typeof t!="symbol")throw new TypeError("RefSet values must be objects, non-registered symbols, or objectified primitives");if(t==null)throw new TypeError("RefSet values cannot be null or undefined");super.add(new WeakRef(t))}addAll(t){if(!t||typeof t!="object"||!Reflect.has(t,Symbol.iterator))throw new TypeError("The supplied values are either falsey or non-iterable");for(let e of t)this.add(e)}clean(){for(let t of this)t.deref()||this.delete(t);return this}entries(){return super.entries().map(([e,s])=>[s.deref(),s.deref()]).filter(([e,s])=>!!s)}forEach(t,e){let s=this;super.forEach(function(n){let i=n.deref();i&&t.call(e,i,i,s)})}values(){let t=[];for(let e of this){let s=e.deref();s&&t.push(s)}return t}keys(){return this.values()}has(t){if(this.#t)return this.contains(t);for(let e of this.values())if(e===t)return!0;return!1}contains(t){return!!Array.from(this.values()).filter(e=>t==e).length}filter(t,e){let s=[];for(let n of this){let i=n?.deref();i&&t.call(e,i,NaN,this)&&s.push(i)}return s}find(t,e){for(let s of this){let n=s?.deref();if(n&&t.call(e,n,NaN,this))return n}}map(t,e,s,n){let i=[],o=!0,a=!0;for(let l of this){let u=l?.deref();if(u){let h=t.call(e,u,NaN,this);(o||a)&&(this.#e(h)||(o=!1,a&&(a=this.#e(Object(h))))),i.push(h)}}if(s){if(o)return new r(i).objectifying(n?this.objectifyValues:!1);if(a)return new r(i.map(l=>this.#e(l)?l:Object(l))).objectifying()}return i}get[Symbol.toStringTag](){return this.constructor.name}#e(t){return!(typeof t=="symbol"&&Symbol.keyFor(t)===void 0||typeof t!="object"&&typeof t!="symbol"||t==null)}},$=new f(P);var R=class{#t=[];constructor(t,...e){t!=null&&typeof t[Symbol.iterator]=="function"?this.#t=[...t,...e]:this.#t=[t,...e]}async*[Symbol.asyncIterator](){for(let t of this.#t)yield Promise.resolve(t)}get[Symbol.toStringTag](){return this.constructor.name}static AsyncIterator=class{constructor(e){if(!e||!Reflect.has(e,Symbol.asyncIterator))throw new TypeError("Value used to instantiate AsyncIterator is not an async iterable");this.#e=e,this.#r=e[Symbol.asyncIterator]()}async asArray(){let e=[];for await(let s of this)e.push(s);return e}get asyncIterable(){return this.#e}async next(){let e=await this.#r.next();return e.done?{value:void 0,done:!0}:{value:e.value,done:!1}}async reset(){this.#r=this.#e[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this}get[Symbol.toStringTag](){return this.constructor.name}#e=null;#r=null};static isAsyncIterable(t){return Object.prototype.toString.call(t?.[Symbol.asyncIterator])==="[object AsyncGeneratorFunction]"}},k=new f(R),F=new f(R.AsyncIterator);var T=class{#t=[];constructor(t,...e){t!=null&&typeof t[Symbol.iterator]=="function"?this.#t=[...t,...e]:this.#t=[t,...e]}*[Symbol.iterator](){for(let t of this.#t)yield t}get asArray(){return this.#t}get[Symbol.toStringTag](){return this.constructor.name}static Iterator=class{constructor(e){if(!e||!Reflect.has(e,Symbol.iterator))throw new TypeError("Value used to instantiate Iterator is not iterable");this.#e=e,this.#r=e[Symbol.iterator]()}get asArray(){return Array.from(this.#e)}get iterable(){return this.#e}next(){let e=this.#r.next();return e.done?{value:void 0,done:!0}:{value:e.value,done:!1}}reset(){this.#r=this.#e[Symbol.iterator]()}[Symbol.iterator](){return this}get[Symbol.toStringTag](){return this.constructor.name}#e=null;#r=null};static isIterable(t){return Object.prototype.toString.call(t?.[Symbol.iterator])==="[object GeneratorFunction]"}},C=new f(T),V=new f(T.Iterator);var K=[Object,Function,Reflect,String,Symbol,Array.prototype],Y=[A,x,k,F,C,V,$];function _(r){let t=r||K;if(!t)throw new Error("Unable to enable features without owners list");t.forEach(e=>{c.enableFor(e)}),G()}function G(){Y.forEach(r=>{r.apply()})}function tt(r){let t=r||K;if(!t)throw new Error("Unable to disable features without owners list");t.forEach(e=>{c.disableFor(e)}),M()}function M(){Y.forEach(r=>{r.revert()})}var et=[p,y,b,S,j,I,A,x].reduce((e,s)=>(Reflect.ownKeys(s.patchEntries).reduce((n,i)=>(e[i]=s.patchEntries[i].computed,e),e),e),{});return L(rt);})();
2
- //# sourceMappingURL=basic-extensions.bundle.1.4.1.js.map