@randajan/jet-core
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -959,2 +959,22 @@ var __defProp = Object.defineProperty; | ||
} | ||
constructor(...items) { | ||
super(...items); | ||
const _p = {}; | ||
Object.defineProperties(this, { | ||
_autoFilter: { get: (_) => _p.autoFilter, set: (fce) => { | ||
if (!jet_default.isRunnable(fce)) { | ||
delete _p.autoFilter; | ||
} else { | ||
this.filter(_p.autoFilter = fce); | ||
} | ||
} }, | ||
_autoSort: { get: (_) => _p.autoSort, set: (fce) => { | ||
if (!jet_default.isRunnable(fce)) { | ||
delete _p.autoSort; | ||
} else { | ||
this.sort(_p.autoSort = fce); | ||
} | ||
} } | ||
}); | ||
} | ||
has(item) { | ||
@@ -991,6 +1011,5 @@ return this.includes(item); | ||
if (items.length) { | ||
const autoFilter = this.autoFilter._current, autoSort = this.autoSort._current; | ||
items = items.flat(); | ||
if (autoFilter) { | ||
items = items.filter(autoFilter); | ||
if (this._autoFilter) { | ||
items = items.filter(this._autoFilter); | ||
} | ||
@@ -1004,4 +1023,4 @@ if (start === this.length) { | ||
} | ||
if (autoSort) { | ||
this.sort(autoSort); | ||
if (this._autoSort) { | ||
this.sort(this._autoSort); | ||
} | ||
@@ -1040,17 +1059,7 @@ } else if (length > 0) { | ||
autoFilter(fce) { | ||
if (!jet_default.isRunnable(fce)) { | ||
delete this.autoFilter._current; | ||
} else { | ||
this.autoFilter._current = fce; | ||
this.filter(fce); | ||
} | ||
this._autoFilter = fce; | ||
return this; | ||
} | ||
autoSort(fce) { | ||
if (!jet_default.isRunnable(fce)) { | ||
delete this.autoSort._current; | ||
} else { | ||
this.autoSort._current = fce; | ||
this.sort(fce); | ||
} | ||
this._autoSort = fce; | ||
return this; | ||
@@ -1063,3 +1072,3 @@ } | ||
var Pool_default = jet_default.define("Pool", Pool, { | ||
copy: (x) => new Pool(...x).autoFilter(x.autoFilter._current).autoSort(x.autoSort._current), | ||
copy: (x) => new Pool(...x).autoFilter(x._autoFilter).autoSort(x._autoSort), | ||
keys: (x) => x.keys(), | ||
@@ -1072,33 +1081,35 @@ vals: (x) => x.values(), | ||
var RunPool = class extends Pool_default { | ||
constructor(...a) { | ||
super(...a); | ||
this.autoFilter(Function.jet.is).with(); | ||
constructor(...items) { | ||
const _p = { with: [] }; | ||
super(...items); | ||
this.autoFilter(jet_default.isRunnable); | ||
Object.defineProperty(this, "_with", { get: (_) => _p.with, set: (v) => _p.with = Array.jet.to(v) }); | ||
} | ||
with(...args) { | ||
this.with._current = args; | ||
this._with = args; | ||
return this; | ||
} | ||
run(...args) { | ||
const r = this.run, first = !r._current; | ||
let rc = r._current = []; | ||
const first = !this._run; | ||
let r = this._run = []; | ||
for (const fce of this) { | ||
rc.push(fce(...this.with._current, ...args)); | ||
if (rc !== r._current) { | ||
r.push(fce(...this._with, ...args)); | ||
if (r !== this._run) { | ||
break; | ||
} | ||
} | ||
rc = r._current; | ||
r = this._run; | ||
if (first) { | ||
delete r._current; | ||
delete this._run; | ||
} | ||
return rc; | ||
return r; | ||
} | ||
fit(...args) { | ||
if (this.fit._current) { | ||
if (this._fit) { | ||
throw "RunPool.fit maximum call stack size exceeded"; | ||
} | ||
this.fit._current = true; | ||
const w = this.with._current; | ||
this._fit = true; | ||
const w = this._with; | ||
const result = jet_default.reducer((next, i, ...a) => this[i] ? this[i](next, ...w, ...a) : a[0])(...w, ...args); | ||
delete this.fit._current; | ||
delete this._fit; | ||
return result; | ||
@@ -1108,3 +1119,3 @@ } | ||
var RunPool_default = jet_default.define("RunPool", RunPool, { | ||
copy: (x) => new RunPool(...x).autoFilter(x.autoFilter._current).autoSort(x.autoSort._current), | ||
copy: (x) => new RunPool(...x).autoFilter(x._autoFilter).autoSort(x._autoSort), | ||
keys: (x) => x.keys(), | ||
@@ -1111,0 +1122,0 @@ vals: (x) => x.values(), |
{ | ||
"name": "@randajan/jet-core", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Ecosystem of types and related usefull tools.", | ||
@@ -5,0 +5,0 @@ "repository": "randajan/jet-core", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118993
1128