@randajan/jet-core
Advanced tools
Comparing version 3.0.11 to 3.1.0
@@ -231,3 +231,3 @@ var __defProp = Object.defineProperty; | ||
var define = (name, constructor, options = {}) => { | ||
let { create, is: is2, full, copy, rnd, keys, vals, entries, get, set, rem, to: to3, extend, extendPrototype, extendConstructor } = options; | ||
let { create, is: is2, full, copy, rnd, keys, vals, entries, get: get2, set, rem, to: to3, extend, extendPrototype, extendConstructor } = options; | ||
if (getDefByName(name)) { | ||
@@ -290,3 +290,3 @@ throwError("is allready defined", name); | ||
ex(2, "entries", entries); | ||
ex(2, "get", get = get || ((x, k) => x[k])); | ||
ex(2, "get", get2 = get2 || ((x, k) => x[k])); | ||
ex(2, "set", set = set || ((x, k, v) => x[k] = v)); | ||
@@ -296,3 +296,3 @@ ex(2, "rem", rem = rem || ((x, k) => delete x[k])); | ||
} | ||
register({ name, constructor, prototype, is: is2, create, full, copy, rnd, keys, vals, entries, get, set, rem, to: {} }); | ||
register({ name, constructor, prototype, is: is2, create, full, copy, rnd, keys, vals, entries, get: get2, set, rem, to: {} }); | ||
toDefine(name, to3); | ||
@@ -328,3 +328,2 @@ if (jc) { | ||
merge: () => merge, | ||
prop: () => prop, | ||
reducer: () => reducer | ||
@@ -444,10 +443,10 @@ }); | ||
const flat = {}; | ||
const add = (v, p) => { | ||
const add2 = (v, p) => { | ||
flat[p] = v; | ||
}; | ||
const deep = (v, p) => { | ||
add(v, p); | ||
forEach(v, add, deep, p); | ||
add2(v, p); | ||
forEach(v, add2, deep, p); | ||
}; | ||
forEach(any, add, includeMapable ? deep : true); | ||
forEach(any, add2, includeMapable ? deep : true); | ||
if (includeMapable) { | ||
@@ -471,3 +470,3 @@ flat[""] = any; | ||
const flat = deflate(r.to, true); | ||
const add = (v, p) => { | ||
const add2 = (v, p) => { | ||
r.to = digIn(r.to, p, v); | ||
@@ -477,3 +476,3 @@ }; | ||
if (!flat[p]) { | ||
add(flat[p] = getDefByInst(v).create(), p); | ||
add2(flat[p] = getDefByInst(v).create(), p); | ||
} | ||
@@ -483,7 +482,7 @@ if (Array.isArray(v) && Array.isArray(flat[p])) { | ||
} else { | ||
forEach(v, add, acumulate, p); | ||
forEach(v, add2, acumulate, p); | ||
} | ||
}; | ||
for (const a of any) { | ||
forEach(a, add, !!overwriteArray || acumulate); | ||
forEach(a, add2, !!overwriteArray || acumulate); | ||
} | ||
@@ -528,26 +527,2 @@ return r.to; | ||
}; | ||
var prop = { | ||
add: (obj, property, val, writable = false, enumerable2 = false, overwrite = true) => { | ||
if (defs_default.isMapable(property)) { | ||
forEach(property, (f, i) => { | ||
const n = String.jet.isNumeric(i); | ||
prop.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; | ||
}, | ||
get: (obj, property) => { | ||
if (!property) { | ||
property = Array.from(Object.getOwnPropertyNames(obj)); | ||
} | ||
if (!defs_default.isMapable(property)) { | ||
return obj[property]; | ||
} | ||
const props = {}; | ||
forEach(property, (k) => props[k] = obj[k]); | ||
return props; | ||
} | ||
}; | ||
var json = { | ||
@@ -572,2 +547,87 @@ from: (json2, throwErr = false) => { | ||
// 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/index.js | ||
@@ -616,2 +676,3 @@ Plex_default.extend(defs_default, { | ||
}, | ||
prop: props_exports, | ||
...pile_exports, | ||
@@ -714,3 +775,3 @@ define: new Plex_default(define_default, { to: toDefine }) | ||
const zoom = Math.pow(10, Math.max(...nums.map((num) => Number.jet.len(num, false)))); | ||
return jet_default.prop.add(nums.map((num) => Math.round(num * zoom)), "zoom", zoom); | ||
return jet_default.prop.solid(nums.map((num) => Math.round(num * zoom)), "zoom", zoom); | ||
}, | ||
@@ -717,0 +778,0 @@ zoomOut: (...nums) => nums.map((num) => num / nums.zoom), |
{ | ||
"name": "@randajan/jet-core", | ||
"version": "3.0.11", | ||
"version": "3.1.0", | ||
"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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
127628
1256
0