Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@randajan/jet-base
Advanced tools
Goal was to create universal structure for storing variables with watcher and validator.
npm install @randajan/jet-base
or
yarn add @randajan/jet-base
import { BaseSync } from "@randajan/jet-base";
const base = new BaseSync();
base.init(true) // initialize base (first argument = debug on/off)
there is also possibility to use 'base.config(true)' instead. Base will be initialized with arguments passed to config function when it will be necessarily
function that simply assign values. For rewrite whole structure it can be used with object as first argument:
base.set({a:1, b:2, c:3, d:{x:123}});
or first argument could be path, and second argument value:
base.set("a", 1);
base.set("b", 2);
base.set("c", 3);
base.set("d.x", 123);
result will be the same.
accessing stored values first argument could be path
base.get("d") == {x:123};
base.get("d.x") === 123;
result is everytime a deep copy.
simple comparing
base.is("d.x", 123) === true;
base.isType("d.x", "Number") === true;
base.isFulll("d.y") === false;
validator of value with middleware iterator. Also accept path as first argument
base.fit("a", (next, value, valueBefore)=>next(value > 0 ? 0 : value));
after defining new validator base will reprocess last input.
run me when variable under path has changed
base.watch("a", (get, changes)=>console.log(get()));
after any change at desired path will be called this function. Passing two arguments. Both are functions. get() will return value at same path and changes() will return list of sub changes;
async version working pretty same
import { BaseAsync } from "@randajan/jet-base";
const base = new BaseAsync();
base.config(true) // config base for later use (first argument = debug on/off)
MIT © randajan
FAQs
Ecosystem of types and related usefull tools.
We found that @randajan/jet-base demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.