@nejs/basic-extensions 1.8.0 → 1.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 +150 -6
- package/dist/@nejs/basic-extensions.bundle.1.8.0.js +4 -0
- package/dist/@nejs/basic-extensions.bundle.1.8.0.js.map +7 -0
- package/dist/cjs/index.d.ts +5 -2
- package/dist/cjs/index.js +25 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/newClasses/deferred.d.ts +126 -0
- package/dist/cjs/newClasses/deferred.js +306 -0
- package/dist/cjs/newClasses/deferred.js.map +1 -0
- package/dist/mjs/index.d.ts +5 -2
- package/dist/mjs/index.js +25 -5
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/newClasses/deferred.d.ts +126 -0
- package/dist/mjs/newClasses/deferred.js +230 -0
- package/dist/mjs/newClasses/deferred.js.map +1 -0
- package/docs/index.html +1128 -162
- package/package.json +3 -3
- package/src/index.js +31 -5
- package/src/newClasses/deferred.js +253 -0
- package/tests/newClasses/deferred.test.js +86 -0
- package/dist/@nejs/basic-extensions.bundle.1.7.0.js +0 -4
- package/dist/@nejs/basic-extensions.bundle.1.7.0.js.map +0 -7
package/README.md
CHANGED
|
@@ -277,14 +277,29 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
|
|
|
277
277
|
* [toStringTag](#tostringtag-2)
|
|
278
278
|
* [isValidReference](#isvalidreference)
|
|
279
279
|
* [Parameters](#parameters-85)
|
|
280
|
-
* [
|
|
280
|
+
* [Deferred](#deferred)
|
|
281
281
|
* [Parameters](#parameters-86)
|
|
282
|
+
* [value](#value-2)
|
|
283
|
+
* [reason](#reason)
|
|
284
|
+
* [settled](#settled)
|
|
285
|
+
* [promise](#promise)
|
|
286
|
+
* [resolve](#resolve)
|
|
287
|
+
* [Parameters](#parameters-87)
|
|
288
|
+
* [reject](#reject)
|
|
289
|
+
* [Parameters](#parameters-88)
|
|
290
|
+
* [species](#species)
|
|
291
|
+
* [promise](#promise-1)
|
|
292
|
+
* [reject](#reject-1)
|
|
293
|
+
* [resolve](#resolve-1)
|
|
294
|
+
* [settled](#settled-1)
|
|
295
|
+
* [AsyncIterable](#asynciterable)
|
|
296
|
+
* [Parameters](#parameters-89)
|
|
282
297
|
* [asyncIterator](#asynciterator)
|
|
283
298
|
* [toStringTag](#tostringtag-3)
|
|
284
299
|
* [isAsyncIterable](#isasynciterable)
|
|
285
|
-
* [Parameters](#parameters-
|
|
300
|
+
* [Parameters](#parameters-90)
|
|
286
301
|
* [AsyncIterator](#asynciterator-1)
|
|
287
|
-
* [Parameters](#parameters-
|
|
302
|
+
* [Parameters](#parameters-91)
|
|
288
303
|
* [asArray](#asarray)
|
|
289
304
|
* [asyncIterable](#asynciterable-1)
|
|
290
305
|
* [next](#next)
|
|
@@ -292,14 +307,14 @@ import { FunctionExtensions } from '@nejs/basic-extensions';
|
|
|
292
307
|
* [asyncIterator](#asynciterator-2)
|
|
293
308
|
* [toStringTag](#tostringtag-4)
|
|
294
309
|
* [Iterable](#iterable)
|
|
295
|
-
* [Parameters](#parameters-
|
|
310
|
+
* [Parameters](#parameters-92)
|
|
296
311
|
* [iterator](#iterator-1)
|
|
297
312
|
* [asArray](#asarray-1)
|
|
298
313
|
* [toStringTag](#tostringtag-5)
|
|
299
314
|
* [isIterable](#isiterable)
|
|
300
|
-
* [Parameters](#parameters-
|
|
315
|
+
* [Parameters](#parameters-93)
|
|
301
316
|
* [Iterator](#iterator-2)
|
|
302
|
-
* [Parameters](#parameters-
|
|
317
|
+
* [Parameters](#parameters-94)
|
|
303
318
|
* [asArray](#asarray-2)
|
|
304
319
|
* [iterable](#iterable-1)
|
|
305
320
|
* [next](#next-1)
|
|
@@ -2112,6 +2127,135 @@ A static method to check if a given value is a valid target for a WeakRef.
|
|
|
2112
2127
|
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the value is a valid WeakRef target,
|
|
2113
2128
|
false otherwise.
|
|
2114
2129
|
|
|
2130
|
+
### Deferred
|
|
2131
|
+
|
|
2132
|
+
**Extends Promise**
|
|
2133
|
+
|
|
2134
|
+
Deferreds, which were first introduced by jQuery for browsers in the early
|
|
2135
|
+
2000s, are a way to manage asynchronous operations. They have been widely
|
|
2136
|
+
used and replicated by engineers since then. Although the Promise class in
|
|
2137
|
+
modern JavaScript provides a static method called `withResolvers` that
|
|
2138
|
+
returns an object with similar properties to a Deferred, it is not directly
|
|
2139
|
+
supported by Node.js.
|
|
2140
|
+
|
|
2141
|
+
const withResolvers = Promise.withResolvers()
|
|
2142
|
+
Reflect.has(withResolvers, 'promise') // true
|
|
2143
|
+
Reflect.has(withResolvers, 'resolve') // true
|
|
2144
|
+
Reflect.has(withResolvers, 'reject') // true
|
|
2145
|
+
|
|
2146
|
+
This Deferred class extends the Promise class, allowing it to capture the
|
|
2147
|
+
value or reason for easy access after resolution, akin to
|
|
2148
|
+
[Promise.withResolvers](Promise.withResolvers). As it extends [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise), it is
|
|
2149
|
+
'thenable' and works with `await` as if it were a native Promise. This
|
|
2150
|
+
allows seamless integration with code expecting Promise-like objects.
|
|
2151
|
+
|
|
2152
|
+
#### Parameters
|
|
2153
|
+
|
|
2154
|
+
* `options` **[object](#object)** see above for examples on supported options, but
|
|
2155
|
+
when supplied, the constructor can take instructions on how to auto
|
|
2156
|
+
resolve or reject the deferred created here.
|
|
2157
|
+
|
|
2158
|
+
#### value
|
|
2159
|
+
|
|
2160
|
+
When the Deferred is settled with [Deferred.resolve](Deferred.resolve), the `value`
|
|
2161
|
+
passed to that function will be set here as well.
|
|
2162
|
+
|
|
2163
|
+
Type: any
|
|
2164
|
+
|
|
2165
|
+
#### reason
|
|
2166
|
+
|
|
2167
|
+
When the Deferred is settled with [Deferred.reject](Deferred.reject), the `reason`
|
|
2168
|
+
passed to that rejection will also be stored here.
|
|
2169
|
+
|
|
2170
|
+
Type: any
|
|
2171
|
+
|
|
2172
|
+
#### settled
|
|
2173
|
+
|
|
2174
|
+
Returns a boolean value that indicates whether or not this Deferred
|
|
2175
|
+
has been settled (either resolve or reject have been invoked).
|
|
2176
|
+
|
|
2177
|
+
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` if either [Deferred.resolve](Deferred.resolve) or
|
|
2178
|
+
[Deferred.reject](Deferred.reject) have been invoked; `false` otherwise
|
|
2179
|
+
|
|
2180
|
+
#### promise
|
|
2181
|
+
|
|
2182
|
+
Accessor for the promise managed by this Deferred instance.
|
|
2183
|
+
|
|
2184
|
+
This getter provides access to the internal promise which is controlled
|
|
2185
|
+
by the Deferred's resolve and reject methods. It allows external code to
|
|
2186
|
+
attach callbacks for the resolution or rejection of the Deferred without
|
|
2187
|
+
the ability to directly resolve or reject it.
|
|
2188
|
+
|
|
2189
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** The promise controlled by this Deferred instance.
|
|
2190
|
+
|
|
2191
|
+
#### resolve
|
|
2192
|
+
|
|
2193
|
+
Resolves the Deferred with the given value. If the value is a thenable
|
|
2194
|
+
(i.e., has a "then" method), the Deferred will "follow" that thenable,
|
|
2195
|
+
adopting its eventual state; otherwise, the Deferred will be fulfilled
|
|
2196
|
+
with the value. This function behaves the same as Promise.resolve.
|
|
2197
|
+
|
|
2198
|
+
##### Parameters
|
|
2199
|
+
|
|
2200
|
+
* `value` **any** The value to resolve the Deferred with.
|
|
2201
|
+
|
|
2202
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** A Promise that is resolved with the given value.
|
|
2203
|
+
|
|
2204
|
+
#### reject
|
|
2205
|
+
|
|
2206
|
+
Rejects the Deferred with the given reason. This function behaves the
|
|
2207
|
+
same as Promise.reject. The Deferred will be rejected with the provided
|
|
2208
|
+
reason.
|
|
2209
|
+
|
|
2210
|
+
##### Parameters
|
|
2211
|
+
|
|
2212
|
+
* `reason` **any** The reason to reject the Deferred with.
|
|
2213
|
+
|
|
2214
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** A Promise that is rejected with the given reason.
|
|
2215
|
+
|
|
2216
|
+
#### species
|
|
2217
|
+
|
|
2218
|
+
A getter for the species symbol which returns a custom DeferredPromise
|
|
2219
|
+
class. This class extends from Deferred and is used to ensure that the
|
|
2220
|
+
constructor signature matches that of a Promise. The executor function
|
|
2221
|
+
passed to the constructor of this class is used to initialize the Deferred
|
|
2222
|
+
object with resolve and reject functions, similar to how a Promise would
|
|
2223
|
+
be initialized.
|
|
2224
|
+
|
|
2225
|
+
Returns **DeferredPromise** A DeferredPromise class that extends Deferred.
|
|
2226
|
+
|
|
2227
|
+
### promise
|
|
2228
|
+
|
|
2229
|
+
The promise backing this deferred object. Created when the constructor
|
|
2230
|
+
runs, this promise is what all `Promise.prototype` functions are routed
|
|
2231
|
+
to.
|
|
2232
|
+
|
|
2233
|
+
Type: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2234
|
+
|
|
2235
|
+
### reject
|
|
2236
|
+
|
|
2237
|
+
The reject() resolver that will be assigned when a new instance is
|
|
2238
|
+
created. Invoking this function with or without a `reason` will cause
|
|
2239
|
+
the deferred's promise to be settled.
|
|
2240
|
+
|
|
2241
|
+
Type: [function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
|
|
2242
|
+
|
|
2243
|
+
### resolve
|
|
2244
|
+
|
|
2245
|
+
The resolve() resolver that will be assigned when a new instance is
|
|
2246
|
+
created. Invoking this function with or without a `value` will cause
|
|
2247
|
+
the deferred's promise to be settled.
|
|
2248
|
+
|
|
2249
|
+
Type: [function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
|
|
2250
|
+
|
|
2251
|
+
### settled
|
|
2252
|
+
|
|
2253
|
+
When either [Deferred.resolve](Deferred.resolve) or [Deferred.reject](Deferred.reject) are called,
|
|
2254
|
+
this property is set to `true`. Its current status at any time can be
|
|
2255
|
+
queried using the [Deferred.settled](Deferred.settled) getter.
|
|
2256
|
+
|
|
2257
|
+
Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
2258
|
+
|
|
2115
2259
|
### AsyncIterable
|
|
2116
2260
|
|
|
2117
2261
|
The AsyncIterable class extends the concept of Iterable to asynchronous
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var nejsBasicExtensions=(()=>{var N=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var lt=(r,t)=>{for(var e in t)N(r,e,{get:t[e],enumerable:!0})},pt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!ut.call(r,o)&&o!==e&&N(r,o,{get:()=>t[o],enumerable:!(s=at(t,o))||s.enumerable});return r};var ht=r=>pt(N({},"__esModule",{value:!0}),r);var Ot={};lt(Ot,{Controls:()=>y,Extensions:()=>O,Patches:()=>R,all:()=>ct,default:()=>Rt});var dt=r=>/(\w+)]/.exec(Object.prototype.toString.call(r))[1],w=class extends Error{constructor(t,e){super(`${dt(t)} disallows tampering with ${e}.`),Object.assign(this,{owner:t,key:e})}get[Symbol.toStringTag](){return this.constructor.name}};var yt=r=>/(\w+)]/.exec(Object.prototype.toString.call(r))[1],S=class extends Error{constructor(t,e){super(`${yt(t)} does not have a property named '${e}'.`),Object.assign(this,{owner:t,key:e})}get[Symbol.toStringTag](){return this.constructor.name}};var x=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 o=this[Symbol.toStringTag],n=`(started: ${this.started} needed: ${this.state.needsApplication})`;return s(`${o} ${n}`,{...e,depth:t})}};var m=class{constructor(t,e=globalThis,s=void 0){let o=c=>c==null,n=(c,l=["string","symbol"])=>!o(c)&&!!l.find(u=>u===typeof c),i=c=>n(c,["object"]);if(!n(t))throw console.error("Property",t,`(type: ${typeof t})`,"owningObject",e,`(type: ${typeof e})`,"condition",s,`(type: ${typeof s})`),new TypeError("Property must be non-null and either a string or symbol");if(!i(e))throw new TypeError("Cannot create Patch entry as owning object is invalid");Object.assign(this,{key:t,descriptor:Object.getOwnPropertyDescriptor(e,t),owner:e,condition:typeof s=="function"?s:void 0})}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 isAllowed(){return this.condition&&typeof this.condition=="function"?this.condition():!0}get[Symbol.toStringTag](){return this.constructor.name}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){let o=this.isData?" Data":" Accessor",n=this.isReadOnly?" [ReadOnly]":"";return`PatchEntry<${this.key}${o}${n}>`}};var a=class r{constructor(t,e,s={}){Object.assign(this,{owner:t,options:s}),this.patchConflicts={},this.patchEntries={},this.patchesOwner=e,this.patchCount=0,this.patchesApplied=0;let o=this?.options.condition;Reflect.ownKeys(e).forEach(n=>{let i=this?.options?.conditions?.[n]??o;try{this.patchEntries[n]=new m(n,this.patchesOwner,i),this.patchCount+=1}catch(c){console.error(`Failed to process patch for ${n}
|
|
2
|
+
`,c)}if(Reflect.has(this.owner,n))try{this.patchConflicts[n]=new m(n,this.owner)}catch(c){console.error(`Cannot capture conflicting patch key ${n}
|
|
3
|
+
`,c)}}),r.patches.has(t)||r.patches.set(t,[]),r.patches.get(t).push(this)}get entries(){return Reflect.ownKeys(this.patchEntries).map(t=>[t,this.patchEntries[t]])}get patches(){return this.entries.reduce((t,[e,s])=>(t[e]=s.computed,t),{})}get conflicts(){return Reflect.ownKeys(this.patchConflicts).map(t=>[t,this.patchConflicts[t]])}get applied(){return this.patchesApplied>0}get isPartiallyPatched(){return this.applied}get isFullyPatched(){return this.patchCount==this.patchesApplied}apply(t){let e=this.entries,s={patches:e.length,applied:0,errors:[],notApplied:e.length};e.forEach(([,o])=>{if(o.isAllowed){Object.defineProperty(this.owner,o.key,o.descriptor);let n=Object.getOwnPropertyDescriptor(this.owner,o.key);this.#t(n,o.descriptor)?(s.applied+=1,s.notApplied-=1):s.errors.push([o,new Error(`Could not apply patch for key ${o.key}`)])}}),this.patchesApplied=s.applied,typeof t=="function"&&t(s)}createToggle(t=!1){return new x(this,t)}revert(t){if(!this.applied)return;let e=this.entries,s=this.conflicts,o={patches:e.length,reverted:0,restored:0,conflicts:s.length,errors:[],stillApplied:0};e.forEach(([,n])=>{delete this.owner[n.key]?(this.patchesApplied-=1,o.reverted+=1):o.errors.push([n,new Error(`Failed to revert patch ${n.key}`)])}),s.forEach(([,n])=>{Object.defineProperty(this.owner,n.key,n.descriptor);let i=Object.getOwnPropertyDescriptor(this.owner,n.key);this.#t(n.descriptor,i)?o.restored+=1:o.errors.push([n,new Error(`Failed to restore original ${n.key}`)])}),o.stillApplied=this.patchesApplied,typeof t=="function"&&t(o)}release(){let t=r.patches.get(this.owner);t.splice(t.find(e=>e===this),1)}owner=null;options=null;#t(t,e){if(!t||!e)return!1;let s=!0;return s=s&&t.configurable===e.configurable,s=s&&t.enumerable===e.enumerable,s=s&&t.value===e.value,s=s&&t.writable===e.writable,s=s&&t.get===e.get,s=s&&t.set===e.set,s}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()}};var mt=["number","boolean","bigint","string","symbol"],f=class r extends a{constructor(t,e,s=globalThis,o={}){let n=r.determineInput(t),{key:i,extension:c,valid:l}=n;if(c=e||c,!l)throw new S(s,i);let u=Object.getOwnPropertyDescriptor(s,i);if(u&&(Reflect.has(u,"writable")&&!u.writable||Reflect.has(u,"configurable")&&!u.configurable))throw new w(s,i);super(s,{[i]:c},o),this.key=i,this.class=n.class,this.function=n.function}get isFunction(){return!!this.function}get isClass(){return!!this.class}get isPrimitive(){return~mt.indexOf(typeof this.value)}get isObject(){return Object(this.value)===this.value}static determineInput(t){let e={key:null,extension:null,valid:!1};return t instanceof Function?(e={key:t.name,extension:t,valid:!0},/^class .*/.exec(t.toString())&&(e.class=t),/^(async )?function .*/.exec(t.toString())&&(e.function=t)):(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 p=new a(Object,{isNullDefined(r){return r==null},hasStringTag(r){return Object.isObject(r)&&Reflect.has(r,Symbol.toStringTag)},getStringTag(r,t=!1){if(Object.hasStringTag(r))return r[Symbol.toStringTag];if(!t)return 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){if(!r||typeof r!="object")throw new TypeError("Object.stripTo requires an object to strip. Received",r);let s={};if(!Array.isArray(t))return s;for(let o of t)if(Reflect.has(r,o)){let i={...Object.getOwnPropertyDescriptor(r,o)};(typeof i.get=="function"||typeof i.set=="function")&&e&&(i.get=i.get?.bind(r),i.set=i.set?.bind(r)),Object.defineProperty(s,o,i)}return s}}),Q=new a(Object.prototype,{stripTo(r,t=!0){return Object.stripTo(this,r,t)}});var{getStringTag:X}=p.patches,T=new a(Function,{isAsync(r){let t=/(\w+)]/g.exec(Object.prototype.toString.call(r))[1];return r instanceof Function&&t.includes("Async")},isAsyncGenerator(r){let t=X(r);return r instanceof Function&&t=="AsyncGeneratorFunction"},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")},isClass(r){return r instanceof Function&&!!/^class\s/.exec(String(r))},isFunction(r){return r instanceof Function&&!Function.isClass(r)},isGenerator(r){let t=X(r);return r instanceof Function&&t=="GeneratorFunction"}}),Z=new a(Function.prototype,{get isAsync(){return Function.isAsync(this)},get isAsyncGenerator(){return Function.isAsyncGenerator(this)},get isBigArrow(){return Function.isBigArrow(this)},get isBound(){return Function.isBound(this)},get isClass(){return Function.isClass(this)},get isFunction(){return Function.isFunction(this)},get isGenerator(){return Function.isGenerator(this)}});var _=new a(Map.prototype,{getKey(r,t=!0){for(let[e,s]of this)return t&&r===s&&!t&&r==s?e:null}});var tt=new a(Set.prototype,{concat(...r){for(let t of r){if(typeof t=="string"||!Reflect.has(t,Symbol.iterator)){this.add(t);continue}for(let e of t)this.add(e)}},contains(r){for(let t of this)if(r==t)return!0;return!1},every(r,t){if(typeof r!="function")throw new TypeError(`everyFn must be a function! Received ${String(r)}`);let e=0;for(let s of this)r.call(t,s,NaN,this)&&e++;return e===this.size},find(r,t){if(typeof r!="function")throw new TypeError(`findFn must be a function! Received ${String(r)}`);for(let e of this)if(r.call(t,e,NaN,this))return e},findLast(r,t){if(typeof r!="function")throw new TypeError(`findFn must be a function! Received ${String(r)}`);let e=[];for(let s of this)r.call(t,s,NaN,this)&&e.push(s);if(e.length)return e[e.length-1]},get length(){return this.size},map(r,t){if(typeof r!="function")throw new TypeError(`mapFn must be a function! Received ${String(r)}`);let e=[];for(let s of this)e.push(r.call(t,s,NaN,this));return e},reduce(r,t,e){if(typeof r!="function")throw new TypeError(`reduceFn must be a Function! Received ${String(r)}`);let s=t;for(let o of this)s=r.call(e,s,o,NaN,this);return s},some(r,t){if(typeof r!="function")throw new TypeError(`someFn must be a function! Received ${String(r)}`);for(let e of this)if(r.call(t,e,NaN,this))return!0;return!1}});var{isObject:et}=p.patches,v=new a(Reflect,{hasAll(r,...t){return Object.isObject(r)&&t.flat(1/0).map(e=>Reflect.has(r,e)).every(e=>e)},ownDescriptors(r){if(!et(r))throw new TypeError("The supplied object must be non-null and an object");let t={},e=Reflect.ownKeys(r);for(let s of e)t[s]=Object.getOwnPropertyDescriptor(s);return t},hasSome(r,...t){return et(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 rt=new a(String,{isString(r){return r&&(typeof r=="string"||r instanceof String)?r.length>0:!1}});var P=new a(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 st=new a(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{isObject:d,isValidKey:k}=p.patches,{hasSome:$}=v.patches,E=class r{#t=void 0;#e=void 0;constructor(t,e){if((t??e)===void 0&&(this.#t=r.enigmatic),r.isDescriptor(t)?(this.#t=t,this.#e=void 0):d(t)&&k(e)&&(this.#t=Object.getOwnPropertyDescriptor(t,e),this.#e=t),!this.isDescriptor)throw console.error("Current descriptor:",this.#t),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}get boundGet(){return d(this.#e)?this.get?.bind(this.#e):this.get}set get(t){(this.#t||{}).get=t}get set(){return(this.#t||{}).set}get boundSet(){return d(this.#e)?this.set?.bind(this.#e):this.set}set set(t){(this.#t||{}).set=t}get hasObject(){return d(this.#e)}get object(){return this.#e}set object(t){this.#e=Object(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,s=!1){return!d(t)||!k(e)||!Reflect.has(t,e)?null:s?new r(Object.getOwnPropertyDescriptor(t,e)):Object.getOwnPropertyDescriptor(t,e)}applyTo(t,e){if(!d(t)||!k(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(!d(t)||!Reflect.has(t,e))return;let s=r.for(t,e,!0);return s.isData?s.value:null}static getAccessor(t,e){if(!d(t)||!Reflect.has(t,e))return;let s=r.for(t,e,!0);return s.isAccessor?s.get.bind(t)():null}static base(t=!1,e=!1){return{enumerable:t,configurable:e}}static accessor(t,e,{enumerable:s,configurable:o}=r.base()){return{get:t,set:e,enumerable:s,configurable:o}}static data(t,e=!0,{enumerable:s,configurable:o}=r.base()){return{value:t,enumerable:s,writable:e,configurable:o}}static isDescriptor(t){let e=[...r.SHARED_KEYS,...r.ACCESSOR_KEYS,...r.DATA_KEYS];return $(t,e)}static isData(t,e){let o=(typeof t=="object"||t instanceof Object)&&e instanceof String?r.for(t,e):t,{DATA_KEYS:n}=this,i=!1;return $(o,n)&&(i=!0),i}static isAccessor(t,e){let o=t&&e&&(typeof t=="object"||t instanceof Object)&&(e instanceof String||typeof e=="symbol")?r.for(t,e):t,{ACCESSOR_KEYS:n}=this,i=!1;return $(o,n)&&(i=!0),i}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"]}},I=new f(E);var{isClass:bt,isFunction:D}=T.patches,gt=Symbol.for("nodejs.util.inspect.custom"),nt=new a(globalThis,{maskAs(r,t,e){let{prototype:s,toPrimitive:o}=GenericMask({...e,prototype:t}),n={configurable:!0,enumerable:!1},i=D(s)?s.prototype:s,c=bt(s)?s:i?.constructor;return!c&&!i?null:(Object.setPrototypeOf(r,i),Object.defineProperties(r,{valueOf:{value(){return String(o("default",r))},...n},[Symbol.toPrimitive]:{value(l){return o(l,r)},...n},[Symbol.toStringTag]:{value:c.name,...n},[Symbol.species]:{get(){return c},...n},[gt]:{...n,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 D(e)||(s.toPrimitive=(o,n)=>{let i=n[t],c=typeof i=="number"&&Number.isFinite(i)||typeof i=="string"&&!isNaN(parseFloat(i))&&isFinite(i);switch(o){case"string":return c?String(i):i??String(n);case"number":return c?Number(i):NaN;case"default":default:return c?Number(i):i}}),s},StringMask(r,t){let e={targetKey:r,toPrimitive:t,prototype:String.prototype};return D(t)||(e.toPrimitive=function(o,n){switch(o){case"default":return n[r];case"number":return parseInt(n[r],36);case"string":return String(n[r]);default:return n}}),e},NumberMask(r,t){let e={targetKey:r,toPrimitive:t,prototype:Number.prototype};return D(t)||(e.toPrimitive=function(o,n){switch(o){case"default":return n[r];case"number":return Number(n[r]);case"string":return String(n[r]);default:return n}}),e}});var F=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 Array.from(super.entries()).map(([e,s])=>[s.deref(),s.deref()]).filter(([e,s])=>!!s)}forEach(t,e){let s=this;super.forEach(function(o){let n=o.deref();n&&t.call(e,n,n,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 o of this){let n=o?.deref();n&&t.call(e,n,NaN,this)&&s.push(n)}return s}find(t,e){for(let s of this){let o=s?.deref();if(o&&t.call(e,o,NaN,this))return o}}map(t,e,s,o){let n=[],i=!0,c=!0;for(let l of this){let u=l?.deref();if(u){let h=t.call(e,u,NaN,this);(i||c)&&(this.#e(h)||(i=!1,c&&(c=this.#e(Object(h))))),n.push(h)}}if(s){if(i)return new r(n).objectifying(o?this.objectifyValues:!1);if(c)return new r(n.map(l=>this.#e(l)?l:Object(l))).objectifying()}return n}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)}},V=new f(F);var ot=new a(WeakRef,{isValidReference(r){return!(typeof r=="symbol"&&Symbol.keyFor(r)===void 0||typeof r!="object"&&typeof r!="symbol"||r==null)}});var A=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 isIterable(t){return Object.prototype.toString.call(t?.[Symbol.iterator])==="[object GeneratorFunction]"}},b=class{#t=void 0;constructor(t,e){if(!t||!Reflect.has(t,Symbol.iterator))throw new TypeError("Value used to instantiate Iterator is not iterable");this.#e=t,this.#r=t[Symbol.iterator](),this.#t=typeof e=="function"?e:void 0}get asArray(){return Array.from(this.#e)}get iterable(){return this.#e}next(){let t=this.#r.next(),e=t;return e.done?{value:void 0,done:!0}:(this.#t&&typeof this.#t=="function"&&(e.value=this.#t(t.value)),{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},C=new f(A),M=new f(b);var{isObject:wt,isNullDefined:St,isValidKey:xt}=p.patches,{isRegistered:Et}=P.patches,{isValidReference:it}=ot.patches,G=class r extends Map{#t=!1;constructor(...t){super(...t)}objectifying(t=!0){return this.objectifyValues=t,this}asObject(){let t={};for(let[e,s]of this){let o=xt(e)?e:String(e),n=s?.valueOf()||s;t[o]=n}return t}get objectifyValues(){return this.#t}get(t,e){let s=super.get(t);return!s||!s?.deref()?e:s?.deref()}set objectifyValues(t){this.#t=!!t}set(t,e){let s=e;if(this.#t&&(typeof s=="number"||typeof s=="string"||typeof s=="boolean"||typeof s=="bigint")&&(s=Object(s)),typeof s=="symbol"&&Symbol.keyFor(s)!==void 0)throw new TypeError("RefMap cannot accept registered symbols as values");if(typeof s!="object"&&typeof s!="symbol")throw new TypeError("RefMap values must be objects, non-registered symbols, or objectified primitives");if(s==null)throw new TypeError("RefMap values cannot be null or undefined");let o=new WeakRef(s);super.set(t,o)}setAll(t){if(!A.isIterable(t))throw new TypeError("The supplied list of entries must be an array of arrays in the format [[key1, value1], [key2, value2], ...].");let e=s=>{let[o,n]=s;!o||!wt(n)||!Et(n)||this.set(o,n)};for(let s of t)e(s);return this}clean(){for(let[t,e]of this)e||this.delete(t);return this}entries(){let t=super.entries();return new b(t,s=>{if(s){let[o,n]=s,i=n?.deref();return[o,i]}return s})}forEach(t,e){for(let[s,o]of super.entries()){let n=o?.deref();n&&t.call(e,n,s,this)}}values(){return new b(super.values(),function(e){return e?.deref()||e})}hasValue(t,e=!0){if(St(t))return!1;this.#t&&(e=!1);for(let[s,o]of this)if(e&&t===o||!e&&t==o)return!0;return!1}filter(t,e){let s=[];for(let[o,n]of this)t.call(e,n,o,this)&&s.push([o,n]);return s}find(t,e){for(let[s,o]of this){let n=super.get(s),i=t.call(e,n,s,map);if(i||(i=t.call(e,o,s,map)),i)return o}return null}map(t,e,s,o){if(typeof t!="function")throw new TypeError("mapFn must be a function! Received",t);let n=[],i=[],c=o&&this.objectifyValues,l=o===void 0,u=c;for(let[h,J]of this){let[,j]=[0,1],g=t.call(e,[h,J],h,this);it(g[j])||it(Object(g[j]))&&(c=!0,l&&!u&&(u=!0,g[j]=Object(g[j]))),n.push(g)}return s?new r(n).objectifying(u):n}*[Symbol.iterator](){for(let[t,e]of this.entries())yield[t,e]}get[Symbol.toStringTag](){return this.constructor.name}},K=new f(G);var B=class r extends Promise{#t=null;#e=null;#r=null;value=null;reason=null;#s=!1;constructor(t){let e=t&&typeof t=="object"?t:{};if(e?.resolve&&e?.reject)throw new TypeError("resolve and reject options cannot be simultaneously provided");let s,o;super((n,i)=>{s=n,o=i,e?.executor&&typeof e?.executor=="function"&&e?.executor(n,i)}),this.#r=n=>(e?.doNotTrackAnswers!==!0&&(this.value=n),this.#s=!0,s(n)),this.#e=async n=>(e?.doNotTrackAnswers!==!0&&(this.reason=n),this.#s=!0,o(n)),this.#t=this,e?.resolve?this.#r(e?.resolve):e?.reject&&this.#e(e?.reject)}get settled(){return this.#s}get promise(){return this.#t}resolve(t){return this.#r(t)}reject(t){return this.#e(t)}static get[Symbol.species](){return class extends r{constructor(e){super({executor:e})}}}},W=new f(B);var Y=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 isAsyncIterable(t){return Object.prototype.toString.call(t?.[Symbol.asyncIterator])==="[object AsyncGeneratorFunction]"}},L=class{constructor(t){if(!t||!Reflect.has(t,Symbol.asyncIterator))throw new TypeError("Value used to instantiate AsyncIterator is not an async iterable");this.#t=t,this.#e=t[Symbol.asyncIterator]()}async asArray(){let t=[];for await(let e of this)t.push(e);return t}get asyncIterable(){return this.#t}async next(){let t=await this.#e.next();return t.done?{value:void 0,done:!0}:{value:t.value,done:!1}}async reset(){this.#e=this.#t[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this}get[Symbol.toStringTag](){return this.constructor.name}#t=null;#e=null},U=new f(Y),q=new f(L);var z=[[Object,p],[Function,T],[Reflect,v],[String,rt],[Symbol,P]],H=[[Object.prototype,Q],[Function.prototype,Z],[Array.prototype,st],[Map.prototype,_],[Set.prototype,tt]],R=new Map([...z,...H]),O={global:nt,[U.key]:U,[q.key]:q,[W.key]:W,[I.key]:I,[C.key]:C,[M.key]:M,[K.key]:K,[V.key]:V},y={};Object.assign(y,{enableAll(){y.enablePatches(),y.enableExtensions()},enablePatches(){R.forEach(r=>{r.apply()})},enableStaticPatches(r=t=>!0){z.filter(r).forEach(t=>t.apply())},enableInstancePatches(r=t=>!0){H.filter(r).forEach(t=>t.apply())},enableExtensions(){Object.values(O).forEach(r=>{r.apply()})},disableAll(){y.disablePatches(),y.disableExtensions()},disablePatches(){R.forEach(r=>{r.revert()})},disableStaticPatches(r=t=>!0){z.filter(r).forEach(t=>t.revert())},disableInstancePatches(r=t=>!0){H.filter(r).forEach(t=>t.revert())},disableExtensions(){Object.values(O).forEach(r=>{r.revert()})}});var ct=[...Array.from(R.values()),...Array.from(Object.values(O))].reduce((e,s)=>(Reflect.ownKeys(s.patchEntries).reduce((o,n)=>{let i=s.patchEntries[n];return i.isAccessor?e[n]=new E(i.descriptor):e[n]=i.computed,e},e),e),{}),At={...y,extensions:O,patches:R,all:ct},Rt=At;return ht(Ot);})();
|
|
4
|
+
//# sourceMappingURL=basic-extensions.bundle.1.8.0.js.map
|