yask
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

yask ~ Your Accessible Storage Knowledge

Documentation: yask Docs

License

Typescript Node Yarn Pnpm NPM

Information

  • 💻 Efficient and fast cache.
  • 🦋 Simple and easy to use.
  • 🔧 Yask CLI.

Important!

This package is in the test and debug phase, its use is recommended as long as you know what you are using, for people with no knowledge about caches its use is not recommended in this phase.

🔧 Installation & Use CLI

npm i yask --save
pnpm add yask --save
yarn add yask --save

npx yask-cli init <folder-to-init-cache>

Why use YASK

📌 Structure

Proximamente!

A simple structure but functional from any side you look at it.

⚡ Flexibility & Scalability

This cache is flexible, non-scalable and is specifically developed for large data management and can be used in any context.

📦 Cache

Its operation is based on an array that manages data within it, using methods as simple as Push, Delete, ForEach and more.

📋 Important Notes:

Read the documentation please!

The errors and/or warnings shown in this documentation are errors/warns that can occur when running yask, they are only informative, a solution can be reached by reading the description of each error/warn.

Methods

Start cache

// Create the cache/ directory and create a file with any name and put the following
import { Cache } from 'yask';

export default new Cache();

// In another file you can import and use the cache without problem
import MyCache from 'path/to/cache/file'

MyCache.Add("Awesome yask cache", "Pointer Reference");

Note:

  • Cache: It is not necessary to create folders or files, you can use them within the same file, it is recommended only if you want to move it throughout the project.

Add

/**
 * @public
 * @param {ResolvableType} value - Value to add in to cache
 * @param {string} reference - Reference to find the pointer
 * @description Add value to cache
 * @returns {number}
 */

MyCache.Add("This value can be of several types", "Pointer Reference");

Note:

  • Pointer Reference: The reference of the pointer is necessary when searching for it, both in Predicates and in other methods, when doing push it is specified to create the pointer with its reference.

Delete

/**
 * @public
 * @param {string} Reference - Reference to find the pointer
 * @description Remove cache table
 * @returns {this}
 */

MyCache.Delete("Pointer Reference");

Edit

/**
 * @public
 * @param {ResolvableType} value - new value
 * @param {PredicateType<ResolvableType>} predicate 
 * @description Edit cached value
 */

MyCache.Edit("New value", (x) => x?.Reference === "Pointer Reference");

Note:

  • New value: It is necessary that the new value to be set coincides with the value to be edited.

Clear

/**
 * @public
 * @description clear cache
 * @returns {number}
 */

MyCache.Clear();

ForEach

/**
 * @public
 * @param {PredicateType<ResolvableType>} predicate 
 * @returns {void}
 */

MyCache.ForEach((x) => {
    if (x?.Reference === "Pointer Reference")
        x?.value = "Hello World!";
});

Find

/**
 * @public
 * @param {PredicateType<ResolvableType>} predicate 
 * @description Search for a value in the cache
 * @returns {ResolvableType}
 */

MyCache.Find((x) => x?.value === "Hello World!");

Exist

/**
 * @public
 * @param {PredicateType<ResolvableType>} predicate 
 * @description Check element exists in to cache by predicate
 * @returns {boolean}
 */

MyCache.Exist((x) => x?.value === "Hello World!");

All

/**
 * @public
 * @description Get all cache
 * @returns {StructureType[]}
 */

MyCache.All();

Size

/**
 * @public
 * @description Get size cache
 * @returns {number}
 */

MyCache.Size();

Check

/**
 * @public
 * @param predicate 
 * @description Check a condition for all tables in the cache
 * @returns {boolean}
 */

MyCache.Check((x) => x?.value != "Hello World!")

Note:

  • Use: The 'Check()' method is used to see if the 'predicate' is true in all tables in the cache.

❗ Possible Errors:

  • (yask-01) The type of the value does not correspond to the new value. This error is because when you edit a value the types of both values (new, old) are not the same.
  • (yask-02) Two pointers cannot have the same reference. This error occurs because two pointers contain the same reference.
  • (yask-03) This pointer does not exist. This is because the pointer, value or reference was not found or not exist.
  • (yask-99) Unknown error. This error is unknown, it may be an unhandled error.

See more

Discord Documentation

Readme

Keywords

Package Sidebar

Install

npm i yask

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

20.1 kB

Total Files

17

Last publish

Collaborators

  • printfdead