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

Ecosystem of types and related usefull tools.

  • 1.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@randajan/jet-base

NPM JavaScript Style Guide

Goal was to create universal structure for storing variables with watcher and validator.

Install

npm install @randajan/jet-base

or

yarn add @randajan/jet-base

Usage

Init

import Base from "@randajan/jet-base";

const base = new Base(true); //first argument = debug mode on/off

Set

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.

Get

accessing stored values first argument could be path

base.get("d") == {x:123};
base.get("d.x") === 123;

result is everytime a deep copy.

Is / IsType / IsFull

simple comparing

base.is("d.x", 123) === true;
base.isType("d.x", "Number") === true;
base.isFulll("d.y") === false;

Fit

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.

Watch

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;

License

MIT © randajan

Keywords

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

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.

Install

Related posts

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