Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@randajan/jet-base

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@randajan/jet-base - npm Package Compare versions

Comparing version 1.2.4 to 2.0.0

189

dist/index.js

@@ -1,2 +0,2 @@

// src/index.js
// src/base.js
import jet3 from "@randajan/jet-core";

@@ -8,8 +8,12 @@

var register = (base) => {
LIST.set(base, {
const priv = {
paths: /* @__PURE__ */ new Set(),
flat: {},
fits: {},
watches: {}
});
watches: {},
state: "pending",
debug: false
};
LIST.set(base, priv);
return priv;
};

@@ -166,11 +170,48 @@

// src/index.js
// src/base.js
var Base = class {
constructor(debug = false) {
Object.defineProperty(this, "debug", { enumerable: true, value: Boolean.jet.to(debug) });
register(this);
constructor() {
const priv = register(this);
const init = this.init.bind(this);
Object.defineProperties(this, {
state: { enumerable: true, get: (_) => priv.state },
debug: { enumerable: true, get: (_) => priv.debug },
init: { value: (...args) => {
if (priv.state !== "pending") {
this.throw("init", `state must be 'pending' insted is '${priv.state}'`);
}
priv.state = "initializing";
if (!priv.config) {
return init(...args);
}
if (args.length) {
this.throw("init", "arguments was predefined with config()");
}
return init(...priv.config);
} }
});
}
log(...msg) {
if (this.debug) {
console.log("jet-base log", ...msg);
}
}
throw(method, msg, path) {
throw `jet-base${method ? ` ${method}(...)` : ""}${path ? ` path '${path}'` : ""} ${msg}`;
}
config(...args) {
config(this, ...args);
return this;
}
init(debug = false) {
const priv = use(this);
priv.debug = Boolean.jet.to(debug);
priv.state = "ready";
return this;
}
autoInit() {
if (this.state === "pending") {
return this.init();
}
}
is(path, value) {

@@ -235,12 +276,134 @@ return get(this, path) === value;

}
log(...msg) {
if (this.debug) {
console.log("jet-base log", ...msg);
}
};
var base_default = Base;
// src/sync.js
var BaseSync = class extends base_default {
is(path, value) {
this.autoInit();
return super.is(path, value);
}
isType(path, type, strict = true) {
this.autoInit();
return super.isType(path, type, strict);
}
isFull(path) {
this.autoInit();
return super.isFull(path);
}
get(path, def) {
this.autoInit();
return super.get(path, def);
}
getType(path, strict = true) {
this.autoInit();
return super.getType(path, strict);
}
set(path, value) {
this.autoInit();
return super.set(path, value);
}
remove(path) {
this.autoInit();
return super.remove(path);
}
pull(path) {
this.autoInit();
return super.pull(path);
}
watch(path, fce, initRun = false) {
this.autoInit();
return super.watch(path, fce, initRun);
}
fit(path, fce) {
this.autoInit();
return super.fit(path, fce);
}
fitTo(path, type, ...args) {
this.autoInit();
return super.fitTo(path, type, ...args);
}
fitType(path, type, strict = true) {
this.autoInit();
return super.fitType(path, type, strict);
}
setDefault(path, value, fullDetect = true) {
this.autoInit();
return super.setDefault(path, value, fullDetect);
}
setLock(path, value) {
this.autoInit();
return super.setLock(path, value);
}
};
var src_default = Base;
var sync_default = BaseSync;
// src/async.js
var BaseAsync = class extends base_default {
async is(path, value) {
await this.autoInit();
return super.is(path, value);
}
async isType(path, type, strict = true) {
await this.autoInit();
return super.isType(path, type, strict);
}
async isFull(path) {
await this.autoInit();
return super.isFull(path);
}
async get(path, def) {
await this.autoInit();
return super.get(path, def);
}
async getType(path, strict = true) {
await this.autoInit();
return super.getType(path, strict);
}
async set(path, value) {
await this.autoInit();
return super.set(path, value);
}
async remove(path) {
await this.autoInit();
return super.remove(path);
}
async pull(path) {
await this.autoInit();
return super.pull(path);
}
async watch(path, fce, initRun = false) {
await this.autoInit();
return super.watch(path, fce, initRun);
}
async fit(path, fce) {
await this.autoInit();
return super.fit(path, fce);
}
async fitTo(path, type, ...args) {
await this.autoInit();
return super.fitTo(path, type, ...args);
}
async fitType(path, type, strict = true) {
await this.autoInit();
return super.fitType(path, type, strict);
}
async setDefault(path, value, fullDetect = true) {
await this.autoInit();
return super.setDefault(path, value, fullDetect);
}
async setLock(path, value) {
await this.autoInit();
return super.setLock(path, value);
}
};
var async_default = BaseAsync;
// src/index.js
var src_default = { BaseSync: sync_default, BaseAsync: async_default };
export {
async_default as BaseAsync,
sync_default as BaseSync,
src_default as default
};
//# sourceMappingURL=index.js.map

4

package.json
{
"name": "@randajan/jet-base",
"version": "1.2.4",
"version": "2.0.0",
"description": "Ecosystem of types and related usefull tools.",

@@ -21,3 +21,3 @@ "repository": "randajan/jet-base",

"peerDependencies": {
"@randajan/jet-core": "^3.0.6"
"@randajan/jet-core": "^3.0.8"
},

@@ -24,0 +24,0 @@ "files": [

@@ -23,7 +23,11 @@ # @randajan/jet-base

```js
import Base from "@randajan/jet-base";
import { BaseSync } from "@randajan/jet-base";
const base = new Base(true); //first argument = debug mode on/off
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
### Set

@@ -76,5 +80,14 @@ function that simply assign values. For rewrite whole structure it can be used with object as first argument:

### Async
async version working pretty same
```js
import { BaseAsync } from "@randajan/jet-base";
const base = new BaseAsync();
base.config(true) // config base for later use (first argument = debug on/off)
```
## License
MIT © [randajan](https://github.com/randajan)

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