New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@randajan/jet-core

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@randajan/jet-core - npm Package Compare versions

Comparing version 3.3.2 to 3.4.0

dist/chunk-OFY25BSF.js

946

dist/index.js

@@ -1,754 +0,5 @@

var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
import {
jet_default
} from "./chunk-QIKZ225C.js";
// src/jet/Plex.js
var Plex = class extends Function {
static extend(self, props = {}) {
for (let i in props) {
Object.defineProperty(self, i, { value: props[i], enumerable: true });
}
return self;
}
constructor(fce, props = {}) {
super();
return Plex.extend(Object.setPrototypeOf(fce ? fce.bind() : this, new.target.prototype), props);
}
};
var Plex_default = Plex;
// src/jet/defs.js
var byName = {};
var byPrototype = /* @__PURE__ */ new Map();
var constructorByName = {};
var defaultThrow = (msg, name) => `jet${name ? ` type '${name}'` : ""} ${msg}`;
var throwError = (msg, name) => {
throw defaultThrow(msg, name);
};
var throwWarn = (msg, name) => {
console.warn(defaultThrow(msg, name));
};
var getDefByName = (name) => byName[name];
var getDefByProto = (prototype) => {
const list = byPrototype.get(prototype);
return list ? list[0] : void 0;
};
var getByInst = (any, def, withDef = true) => {
if (!def.is || def.is(any)) {
return withDef ? def : def.name;
}
};
var findByProto = (any, proto, withDef = true) => {
const list = byPrototype.get(proto);
if (!list) {
return;
}
if (list.length === 1) {
return getByInst(any, list[0], withDef);
}
for (const def of list) {
const r = getByInst(any, def, withDef);
if (r) {
return r;
}
}
};
var findByInst = (any, strict, withDef = true) => {
if (any == null) {
return;
}
if (strict) {
return findByProto(any, any.__proto__, withDef);
}
let r, p = any;
do {
r = findByProto(any, p = p.__proto__, withDef);
} while (p && r === void 0);
return r;
};
var getDefByInst = (any, strict = true) => findByInst(any, strict, true);
var getNameByInst = (any, strict = true) => findByInst(any, strict, false);
var register = (def) => {
byName[def.name] = def;
Object.defineProperty(constructorByName, def.name, { enumerable: true, value: def.constructor });
const list = byPrototype.get(def.prototype);
if (list) {
list.unshift(def);
} else {
byPrototype.set(def.prototype, [def]);
}
};
var defs_default = new Plex_default(getNameByInst, {
types: constructorByName
});
// src/jet/methods.js
var _magic = ["only", "full", "tap", "pull", "is", "to", "copy", "rnd"];
var isInstance = (any) => {
const t = typeof any;
return any != null && (t === "function" || t === "object");
};
var isInstanceOf = (constructor, any) => any instanceof constructor;
var is = (name, any, strict = true) => {
if (!name) {
return false;
}
const def = getDefByName(name);
if (def) {
if (any == null) {
return false;
}
if (strict && any.__proto__ !== def.prototype) {
return false;
}
if (!strict && !(any instanceof def.constructor)) {
return false;
}
return !def.is || def.is(any);
}
const nt = typeof name;
if (nt === "string") {
return typeof any === name;
}
if (any == null || nt !== "function" && nt !== "object") {
return false;
}
return strict ? any.constructor === name : any instanceof name;
};
var isFull = (any, vals) => {
if (!vals) {
return any === false || any === 0 || !!any;
}
for (let v of vals(any)) {
if (v != null) {
return true;
}
}
return false;
};
var _touch = (def, op, err, ...args) => {
if (def[op]) {
return def[op](...args);
}
if (err) {
throwError(`undefined operation '${op}' - unavailable for this type`, def.name);
}
};
var touch = (name, op, err, ...args) => {
const def = getDefByName(name);
if (def) {
return _touch(def, op, err, ...args);
}
if (err) {
throwError(`unable execute '${op}' - type unknown`, name);
}
};
var touchBy = (any, op, err, ...args) => {
const def = getDefByInst(any, false);
if (def) {
return _touch(def, op, err, any, ...args);
}
if (err) {
throwError(`unable execute '${op}' - missing type of '${any}'`);
}
};
var factory = (name, mm, ...args) => {
const def = getDefByName(name);
const n = isInstance(name);
if (n && mm > 0) {
throwError(`unable execute '${_magic[mm]}' - unavailable for plain constructors`);
}
if (name && !n && !def) {
throwError(`unable execute '${_magic[mm]}' - type unknown`, name);
}
if (!name && mm !== 1) {
throwError(`unable execute '${_magic[mm]}' - type missing`);
}
for (const a of args) {
if (!n) {
const at = getDefByInst(a);
if ((!name || at && at.name === name) && (mm !== 1 || (at && at.isFull(a) || !at && isFull(a)))) {
return mm === 3 ? at.copy(a) : a;
}
} else if (isInstanceOf(name, a)) {
return a;
}
}
if (mm > 1) {
return def.create();
}
};
var to = (name, any, ...args) => {
const def = getDefByName(name);
if (!def) {
throwError(`unable execute 'to' - type unknown`, name);
}
const at = getDefByInst(any, false);
if (!at) {
return def.create();
}
if (def.name === at.name) {
return any;
}
const exe = at.to[name] || at.to["*"];
return exe ? to(name, exe(any, ...args), ...args) : def.create(any);
};
var defineTo = (from, to3, exe) => {
const tt = typeof to3;
const def = getDefByName(from);
if (!def) {
throwError(`unable define 'to' - type unknown`, from);
}
const conv = def.to;
if (tt === "function") {
conv["*"] = to3;
} else if (tt === "object" && Array.isArray(to3)) {
for (let i in to3) {
conv[to3[i]] = exe;
}
} else if (tt === "object") {
for (let i in to3) {
conv[i] = to3[i];
}
} else {
conv[to3] = exe;
}
};
var getRND = (arr, min, max, sqr) => {
if (!arr) {
return;
}
arr = Array.from(arr);
const l = arr.length;
return arr[Math.floor(Number.jet.rnd(Number.jet.frame(min || 0, 0, l), Number.jet.frame(max || l, 0, l), sqr))];
};
// src/jet/extend.js
var _prototypeExtenders = {};
var enumerable = true;
var _extend = (name, isNative, key, val, jc, jp) => {
const rnbl = typeof val === "function";
if (jp) {
Object.defineProperty(jp, key, { enumerable, value: rnbl ? function(...a) {
return val(this.___, ...a);
} : val });
}
if (jc) {
Object.defineProperty(jc, key, { enumerable, value: val });
}
if (isNative && defs_default[key]) {
Object.defineProperty(defs_default[key], name, { enumerable, value: val });
}
};
var defineExtend = (name, extendConstructor = {}, extendPrototype = {}, isNative = false) => {
const def = getDefByName(name);
if (!def) {
throwError(`unable define 'extend' - type unknown`, name);
}
const c = def.constructor;
const p = c.prototype;
const ec = extendConstructor === false ? null : typeof extendConstructor === "object" ? extendConstructor : {};
const ep = extendPrototype === false ? null : typeof extendPrototype === "object" ? extendPrototype : {};
let jc = c.jet, jp = _prototypeExtenders[name];
if (ep && !jp) {
jp = _prototypeExtenders[name] = {};
Object.defineProperty(p, "jet", { get: function() {
return { ___: this, ...jp };
} });
}
if (jc) {
for (const k in ec) {
_extend(name, isNative, k, ec[k], jc);
}
}
if (jp) {
for (const k in ep) {
_extend(name, isNative, k, ep[k], jc, jp);
}
}
return true;
};
// src/jet/define.js
var accepts = ["create", "is", "isFull", "copy", "rnd", "keys", "vals", "entries", "get", "set", "rem", "to", "extend", "extendPrototype", "extendConstructor"];
var define = (name, constructor, options = {}) => {
if (getDefByName(name)) {
throwError("is allready defined", name);
}
if (!constructor) {
throwError("constructor missing", name);
}
let { create, is: is2, isFull: isFull2, copy, rnd, keys, vals, entries, get: get2, set, rem, to: to3, extend, extendPrototype, extendConstructor } = options;
const unknownOptions = Object.keys(options).filter((opt) => !accepts.includes(opt));
if (unknownOptions.length) {
throwWarn(`unknown options appeared at definition. '${unknownOptions.join("', '")}'`, name);
}
if ((keys || vals || entries) && !(keys && vals && entries)) {
throwError("keys, vals or entries missing", name);
}
const prototype = constructor.prototype;
const ancestor = getDefByProto(prototype);
create = create || ((...a) => new constructor(...a));
copy = copy || ((any) => any);
rnd = rnd || create;
isFull2 = isFull2 || ((any) => isFull(any, vals));
if (entries) {
get2 = get2 || ((x, k) => x[k]);
set = set || ((x, k, v) => x[k] = v);
rem = rem || ((x, k) => delete x[k]);
}
register({ name, constructor, prototype, is: is2, create, isFull: isFull2, copy, rnd, keys, vals, entries, get: get2, set, rem, to: {} });
defineTo(name, to3);
if (extend !== false) {
if (ancestor) {
throwWarn(`constructor allready extended as '${ancestor.name}'. Use option 'extend:false'`, name);
} else {
Object.defineProperty(constructor, "jet", { value: {}, writable: true });
const ecn = {
create,
rnd,
is: (any, strict = true) => is(name, any, strict),
to: (any, ...a) => to(name, any, ...a),
only: (...a) => factory(name, 0, ...a),
full: (...a) => factory(name, 1, ...a),
tap: (...a) => factory(name, 2, ...a),
pull: (...a) => factory(name, 3, ...a)
};
const epn = entries ? { isFull: isFull2, keys, vals, entries, get: get2, set, rem, getRND: (any, min, max, sqr) => getRND(vals(any), min, max, sqr) } : { isFull: isFull2 };
defineExtend(name, extendConstructor === false ? false : ecn, extendPrototype === false ? false : epn, true);
defineExtend(name, extendConstructor, extendPrototype);
}
}
return constructor;
};
var define_default = define;
// src/jet/pile.js
var pile_exports = {};
__export(pile_exports, {
assign: () => assign,
compare: () => compare,
deflate: () => deflate,
dig: () => dig,
digIn: () => digIn,
digOut: () => digOut,
enumFactory: () => enumFactory,
forEach: () => forEach,
inflate: () => inflate,
json: () => json,
map: () => map,
melt: () => melt,
merge: () => merge,
reducer: () => reducer,
vault: () => vault
});
var _each = ({ create, entries, set }, any, fce, deep, dprun, dir, flat, stop, isStop) => {
const res = flat || create();
for (let [key, val] of entries(any)) {
const path = (dir ? dir + "." : "") + key;
const def = deep || !fce ? getDefByInst(val) : null;
const dp = deep && def && def.entries;
if (!dp) {
val = fce ? fce(val, path, dir, key, stop) : def ? def.copy(val) : val;
} else if (dprun) {
val = deep(val, path, dir, key, stop);
} else {
val = _each(def, val, fce, deep, dprun, path, flat, stop, isStop);
}
if (val !== void 0) {
if (!flat) {
set(res, key, val);
} else if (!dp) {
flat.push(val);
}
}
if (isStop()) {
break;
}
}
;
return res;
};
var _eachInit = (any, fce, deep, dir, flat) => {
const df = getDefByInst(any);
dir = String.jet.to(dir, ".");
let _stop, stop = (_) => _stop = true;
if (df && df.entries) {
return _each(
df,
any,
fce,
deep,
defs_default.isRunnable(deep),
dir,
flat,
stop,
(_) => _stop
);
}
;
const val = fce ? fce(any, dir, "", dir, stop) : df.copy ? df.copy(any) : any;
if (flat && val !== void 0) {
flat.push(val);
}
return flat || val;
};
var forEach = (any, fce, deep = false, dir = "") => _eachInit(any, fce, deep, dir, []);
var map = (any, fce, deep = false, dir = "") => _eachInit(any, fce, deep, dir);
var reducer = (reductor) => {
let i = 0, next;
return next = (...input) => reductor(next, i++, ...input);
};
var dig = (any, path, reductor) => {
const pa = String.jet.to(path, ".").split(".");
const end = pa.length - 1;
return reducer((next, index, parent) => {
const dir = pa.slice(0, index).join(".");
return reductor(next, parent, (dir ? dir + "." : "") + pa[index], dir, pa[index], index === end);
})(any);
};
var digOut = (any, path, def) => {
path = String.jet.to(path, ".");
if (!path) {
return any;
}
for (let p of path.split(".")) {
if (null == (any = defs_default.get(any, p, false))) {
return def;
}
}
return any;
};
var digIn = (any, path, val, force = true, reductor = void 0) => {
const step = (next, parent, path2, dir, key, isEnd) => {
let df = getDefByInst(parent);
if (!df || !df.entries) {
if (!force) {
return parent;
}
parent = String.jet.isNumeric(key) ? [] : {};
df = getDefByInst(parent);
}
const v = isEnd ? val : next(df.get(parent, key, false));
if (v != null) {
df.set(parent, key, v, false);
return parent;
}
df.rem(parent, key);
if (df.isFull(parent)) {
return parent;
}
};
return dig(
any,
path,
!defs_default.isRunnable(reductor) ? step : (next, parent, path2, dir, key, isEnd) => reductor(
(parent2) => step(next, parent2, path2, dir, key, isEnd),
parent,
path2,
dir,
key,
isEnd
)
);
};
var deflate = (any, includeMapable = false) => {
const flat = {};
const add2 = (v, p) => {
flat[p] = v;
};
const deep = (v, p) => {
add2(v, p);
forEach(v, add2, deep, p);
};
forEach(any, add2, includeMapable ? deep : true);
if (includeMapable) {
flat[""] = any;
}
return flat;
};
var inflate = (flat, includeMapable = true) => {
const r = {};
for (const e of defs_default.keys(flat).sort()) {
if (!includeMapable && defs_default.isMapable(flat[e])) {
continue;
}
digIn(r, "to." + e, flat[e], true);
}
return r.to;
};
var _assign = (overwriteArray, to3, ...any) => {
const r = { to: to3 };
const flat = deflate(r.to, true);
const add2 = (v, p) => {
r.to = digIn(r.to, p, v);
};
const acumulate = (v, p) => {
if (!flat[p]) {
add2(flat[p] = getDefByInst(v).create(), p);
}
if (Array.isArray(v) && Array.isArray(flat[p])) {
flat[p].push(...v);
} else {
forEach(v, add2, acumulate, p);
}
};
for (const a of any) {
forEach(a, add2, !!overwriteArray || acumulate);
}
return r.to;
};
var assign = (to3, from, overwriteArray = true) => _assign(overwriteArray, to3, from);
var merge = (...any) => _assign(false, {}, ...any);
var compare = (a, b, changeList = false) => {
const res = [];
if (!changeList && a === b) {
return true;
}
const flat = deflate(a);
forEach(b, (v, p, d, k, stop) => {
if (flat[p] !== v) {
res.push(p);
}
delete flat[p];
if (res.length && !changeList) {
stop();
}
}, true);
for (let p in flat) {
if (res.length && !changeList) {
break;
}
res.push(p);
}
return changeList ? res : !res.length;
};
var melt = (any, comma) => {
let j = "", c = String.jet.to(comma);
if (!defs_default.isMapable(any)) {
return String.jet.to(any, c);
}
forEach(any, (v) => {
v = melt(v, c);
j += v ? (j ? c : "") + v : "";
});
return j;
};
var vault = (name) => {
console.warn(`jet.vault("${name}") being deprecated use native WeakMap instead`);
const vault2 = {};
let keyNext = 1;
return {
set: (data) => {
const key = Symbol(`$$` + (name || "vault") + keyNext++);
return [key, vault2[key] = data];
},
get: (key, path, def) => path ? digOut(vault2[key], path, def) : vault2[key],
end: (key) => delete vault2[key]
};
};
var enumFactory = (enums, { before, after, def } = {}) => (raw, ...args) => {
const input = before ? before(raw, ...args) : raw;
const output = enums.includes(input) ? input : def;
return after ? after(output, ...args) : output;
};
var json = {
from: (json2, throwErr = false) => {
if (defs_default.isMapable(json2)) {
return json2;
}
try {
return JSON.parse(String.jet.to(json2));
} catch (e) {
if (throwErr === true) {
throw e;
}
}
},
to: (obj, prettyPrint = false) => {
const spacing = Number.jet.only(prettyPrint === true ? 2 : prettyPrint);
return JSON.stringify(defs_default.isMapable(obj) ? obj : {}, null, spacing);
}
};
// src/jet/props.js
var props_exports = {};
__export(props_exports, {
add: () => add,
cached: () => cached,
get: () => get,
safe: () => safe,
solid: () => solid,
virtual: () => virtual
});
var add = (obj, property, val, writable = false, enumerable2 = false, overwrite = true) => {
if (jet.isMapable(property)) {
jet.forEach(property, (f, i) => {
const n = String.jet.isNumeric(i);
add(obj, n ? f : i, n ? val : f, writable, enumerable2, overwrite);
});
} else if (!obj[property] || overwrite) {
Object.defineProperty(obj, property, { value: val, writable, configurable: writable, enumerable: enumerable2 });
}
return obj;
};
var get = (obj, property) => {
if (!property) {
property = Array.from(Object.getOwnPropertyNames(obj));
}
if (!jet.isMapable(property)) {
return obj[property];
}
const props = {};
jet.forEach(property, (k) => props[k] = obj[k]);
return props;
};
var solid = new Plex_default(
(obj, name, value, enumerable2 = true) => Object.defineProperty(obj, name, { enumerable: enumerable2, value }),
{
all: (obj, namedValues, enumerable2 = true) => {
for (const [name, value] of Object.entries(namedValues)) {
solid(obj, name, value, enumerable2);
}
return obj;
}
}
);
var virtual = new Plex_default(
(obj, name, get2, enumerable2 = true) => Object.defineProperty(obj, name, { enumerable: enumerable2, get: get2 }),
{
all: (obj, namedGets, enumerable2 = true) => {
for (const [name, get2] of Object.entries(namedGets)) {
virtual(obj, name, get2, enumerable2);
}
return obj;
}
}
);
var safe = new Plex_default(
(obj, priv, name, set, get2, enumerable2 = true) => {
return Object.defineProperty(obj, name, {
set: set ? (v) => priv[name] = set(v, priv[name], name) : void 0,
get: get2 ? (_) => get2(priv[name], name) : (_) => priv[name],
enumerable: enumerable2
});
},
{
all: (obj, priv, namedSetsAndGets, enumerable2 = true) => {
for (const [name, { set, get: get2 }] of Object.entries(namedSetsAndGets)) {
safe(obj, priv, name, set, get2, enumerable2);
}
return obj;
}
}
);
var cached = new Plex_default(
(obj, priv, name, set, enumerable2 = true) => {
return safe(obj, priv, name, null, (v) => v != null ? v : priv[name] = set(name), enumerable2);
},
{
all: (obj, priv, namedSets, enumerable2 = true) => {
for (const [name, set] of Object.entries(namedSets)) {
cached(obj, priv, name, set, enumerable2);
}
return obj;
}
}
);
// src/jet/buffer.js
var buffer = (processQueue, bufferMs = 100, maxQueueMs = 0, maxQueueSize = 0) => {
if (!defs_default.isRunnable(processQueue)) {
throw new Error("jet.buffer(...) require function as a first argument");
}
bufferMs = Math.max(0, Number.jet.to(bufferMs));
maxQueueMs = Math.max(0, Number.jet.to(maxQueueMs));
maxQueueSize = Math.max(0, Number.jet.to(maxQueueSize));
let intA, intB, queue = [];
const execute = (_) => {
clearTimeout(intA);
clearTimeout(intB);
const q = queue;
queue = [];
processQueue(q);
};
return (...args) => {
clearTimeout(intA);
if (maxQueueSize && queue.length >= maxQueueSize) {
return execute();
}
queue.push(args);
intA = setTimeout(execute, bufferMs);
if (maxQueueMs > bufferMs && queue.length === 1) {
intB = setTimeout(execute, maxQueueMs);
}
};
};
// src/jet/index.js
Plex_default.extend(defs_default, {
is,
to,
isFull: (any) => {
const def = getDefByInst(any, false);
return def ? def.isFull(any) : isFull(any);
},
isMapable: (any, strict = true) => {
const def = getDefByInst(any, strict);
return def ? !!def.entries : false;
},
isRunnable: (any) => typeof any === "function",
full: (...a) => factory(null, 1, ...a),
only: (name, ...a) => factory(name, 0, ...a),
tap: (name, ...a) => factory(name, 2, ...a),
pull: (name, ...a) => factory(name, 3, ...a),
create: (name, ...a) => touch(name, "create", true, ...a),
rnd: (name, ...a) => touch(name, "rnd", true, ...a),
copy: (any, deep = false, copyUnmapable = false) => deep ? defs_default.map(any, copyUnmapable ? void 0 : (_) => _, true) : touchBy(any, "copy"),
keys: (any, throwError2 = false) => touchBy(any, "keys", throwError2) || [],
vals: (any, throwError2 = false) => touchBy(any, "vals", throwError2) || [],
entries: (any, throwError2 = false) => touchBy(any, "entries", throwError2) || [],
get: (any, key, throwError2 = false) => touchBy(any, "get", throwError2, key),
set: (any, key, val, throwError2 = false) => touchBy(any, "set", throwError2, key, val),
rem: (any, key, throwError2 = true) => touchBy(any, "rem", throwError2, key),
uid: (length = 12, pattern = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") => {
let r = "";
pattern = String.jet.to(pattern) || "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
while (r.length < length) {
r += defs_default.getRND(pattern);
}
return r;
},
getRND: (any, min, max, sqr) => {
const def = getDefByInst(any);
if (def && def.vals) {
any = def.vals(any);
} else if (typeof any === "string") {
return getRND(any, min, max, sqr);
}
},
run: (any, ...args) => {
if (defs_default.isRunnable(any)) {
return any(...args);
}
if (!defs_default.isMapable(any)) {
return void 0;
}
return defs_default.forEach(any, (f) => defs_default.isRunnable(f) ? f(...args) : void 0, true);
},
prop: props_exports,
buffer,
...pile_exports,
define: new Plex_default(define_default, { to: defineTo, extend: defineExtend })
});
defs_default.define("Plex", Plex_default, {
copy: (x) => Object.defineProperties({}, Object.getOwnPropertyDescriptors(x)),
keys: (x) => Object.keys(x),
vals: (x) => Object.values(x),
entries: (x) => Object.entries(x)
});
var jet_default = defs_default;
// src/native/Object.js

@@ -1032,6 +283,6 @@ var Object_default = jet_default.define("Object", Object, {

// src/native/Symbol.js
var to2 = (sym) => String(sym).slice(7, -1);
var to = (sym) => String(sym).slice(7, -1);
var Symbol_default = jet_default.define("Symbol", Symbol, {
create: Symbol,
copy: (x) => Symbol(to2(x)),
copy: (x) => Symbol(to(x)),
rnd: (...a) => Symbol(jet_default.rnd.String(...a)),

@@ -1104,3 +355,3 @@ to: {

create: (x) => !x ? new Date() : new Date(x),
rnd: (from, to3) => new Date(Number.jet.rnd(new Date(from).getTime(), to3 ? new Date(to3).getTime() : Date.now() * 2)),
rnd: (from, to2) => new Date(Number.jet.rnd(new Date(from).getTime(), to2 ? new Date(to2).getTime() : Date.now() * 2)),
to: {

@@ -1170,4 +421,4 @@ Function: (date) => (_) => date

extendPrototype: {
swap: (arr, to3, from) => {
[arr[to3], arr[from]] = [arr[from], arr[to3]];
swap: (arr, to2, from) => {
[arr[to2], arr[from]] = [arr[from], arr[to2]];
return arr;

@@ -1309,182 +560,9 @@ },

to: {
Function: (map2) => (_) => map2
Function: (map) => (_) => map
}
});
// src/custom/Pool.js
var Pool = class extends Array {
static pass(from, to3, start, length = 1) {
if (!Array.isArray(from)) {
throw "Pool.pass 'from' require array";
}
if (!Array.isArray(to3)) {
throw "Pool.pass 'to' require array";
}
return to3.push(...from.splice(start, length)) >= 0;
}
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) {
return this.includes(item);
}
add(...items) {
this.splice(-1, 0, ...items);
return (_) => this.remove(...items);
}
remove(...items) {
return this.filter((v) => !items.includes(v));
}
push(...items) {
this.splice(-1, 0, ...items);
return this;
}
unshift(...items) {
this.splice(0, 0, ...items);
return this;
}
put(start, ...items) {
this.splice(start, 0, ...items);
return this;
}
splice(start, length = 1, ...items) {
let result;
if (length < 0) {
length = 0;
}
if (start < 0) {
start = Math.max(0, this.length + start + 1 - length);
}
if (items.length) {
items = items.flat();
if (this._autoFilter) {
items = items.filter(this._autoFilter);
}
if (start === this.length) {
super.push(...items);
} else if (start === 0) {
super.unshift(...items);
} else {
result = super.splice(start, length, ...items);
}
if (this._autoSort) {
this.sort(this._autoSort);
}
} else if (length > 0) {
result = super.splice(start, length);
}
return result || new Pool();
}
passTo(to3, start, length = 1) {
return Pool.pass(this, to3, start, length);
}
passFrom(from, start, length = 1) {
return Pool.pass(from, this, start, length);
}
flush() {
return super.splice(0, this.length);
}
filter(fce) {
let k = 0;
for (let i = 0; i < this.length; i++) {
if (fce(this[i], i, this)) {
this[k++] = this[i];
}
}
this.length = k;
return this;
}
map(fce) {
const r = [];
for (let i = this.length - 1; i >= 0; i--) {
r.push(fce(this[i], i, this));
}
return r;
}
autoFilter(fce) {
this._autoFilter = fce;
return this;
}
autoSort(fce) {
this._autoSort = fce;
return this;
}
toString(separator = " ") {
return jet_default.melt(this, String.jet.to(separator, this));
}
};
var Pool_default = jet_default.define("Pool", Pool, {
copy: (x) => new Pool(...x).autoFilter(x._autoFilter).autoSort(x._autoSort),
keys: (x) => x.keys(),
vals: (x) => x.values(),
entries: (x) => x.entries()
});
// src/custom/RunPool.js
var RunPool = class extends Pool_default {
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 = args;
return this;
}
run(...args) {
const first = !this._run;
let r = this._run = [];
for (const fce of this) {
r.push(fce(...this._with, ...args));
if (r !== this._run) {
break;
}
}
r = this._run;
if (first) {
delete this._run;
}
return r;
}
fit(...args) {
if (this._fit) {
throw "RunPool.fit maximum call stack size exceeded";
}
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;
return result;
}
};
var RunPool_default = jet_default.define("RunPool", RunPool, {
copy: (x) => new RunPool(...x).autoFilter(x._autoFilter).autoSort(x._autoSort),
keys: (x) => x.keys(),
vals: (x) => x.values(),
entries: (x) => x.entries()
});
// src/index.js
var src_default = jet_default;
var Plex2 = jet_default.types.Plex;
var Plex = jet_default.types.Plex;
export {

@@ -1500,7 +578,5 @@ Array_default as Array,

Object_default as Object,
Plex2 as Plex,
Pool_default as Pool,
Plex,
Promise_default as Promise,
RegExp_default as RegExp,
RunPool_default as RunPool,
Set_default as Set,

@@ -1507,0 +583,0 @@ String_default as String,

{
"name": "@randajan/jet-core",
"version": "3.3.2",
"version": "3.4.0",
"description": "Ecosystem of types and related usefull tools.",

@@ -10,3 +10,6 @@ "repository": "randajan/jet-core",

"exports": {
".": "./dist/index.js"
".": "./dist/index.js",
"./pool": "./dist/extra/Pool.js",
"./runpool": "./dist/extra/RunPool.js",
"./ticker": "./dist/extra/Ticker.js"
},

@@ -13,0 +16,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc