1.1.1 • Published 2 years ago

@wave-dev/plugins v1.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Packcages

  • @wave-dev/plugins (source) Useful plugins for development.

Instalation

Node.js 16.9.0 or newer is required.

npm install @wave-dev/plugins

List of available plugins

  • KVString allows you to store data by (key:value) pairs in a single string and format it interpreting it as different data types as well. This was powered by Discord Bot Development. In order to avoid databases and collection for storing short data, i use strings to do it in the Message Component Custom ID So whenever i need to store the target of an interaction or command, page or any other data, this is a strong way to do it because it will be exiting forever until the message/component get deleted.

    // Creating it from the constructor:
    import { KVString } from "@wave-dev/plugins";
    const myKVString = new KVString({
      // Setting the values with their keys
      values: [
        { key: "name", value: "Sam" },
        { key: "age", value: "20" },
      ],
      // Specifying the max length for the result string
      maxLength: 100,
    });
    // Creating it by its methods
    import { KVString } from "@wave-dev/plugins";
    const myKVString = new KVString();
    myKVString.setMaxLength(100);
    myKVString.addValue("name", "Sam");
    if (true) myKVString.addValue("age", "20");
    // Getting data
    const name = myKVString.getString("name", true); // "Sam"
    const age = myKVString.getNumber("age", true); // 20
    const surname = myKVString.getString("surname"); // undefined
    const petName = myKVString.getString("petName", true); // Error (Unnnable to get the value named petName)
    const { name, age } = myKVString.toObject("name", "age"); // All properties are of type string
    console.log(name); // "Sam"
    console.log(parseInt(age)); // 20
  • StringBuilder allows you to dynamicaly create an string.

    import { StringBuilder } from "@wave-dev/plugins";
    const content = new StringBuilder("Hummmm...");
    if (1 + 1 === 2) content.update("it's true!", ", ");
    console.log(content.toString()); // "Hummmm..., it's true!"
  • stringEquals allows you to get the equality between two strings with additional options.
    import { stringEquals } from "@wave-dev/plugins";
    stringEquals("Apple", "Apple"); // true
    stringEquals("My name is Jhon", "JHON", {
      allowCaseSensitive: true,
      allowIncludes: "booth",
    }); // true
  • JSONStorage allows you to store JSON data in JSON files like a local Database.

    // fruits.ts
    import { JSONStorage, BaseDocumentData } from "@wave-dev/plugins";
    import { join } from "path";
    // Create an interface for the document data
    interface FruitData extends BaseDocumentData {
      name: string;
      amount: number;
    }
    // Create the dir and JSON file
    const Fruits = new JSONStorage<FruitData>(
      process.cwd(),
      "storage",
      "fruits.json"
    );
    // Create the first document
    Fruits.create({ id: "12345678912345678", name: "Apple", amount: 1 });
    // Get the document by its id
    const fruit = Fruits.getById("12345678912345678", true);
    // Modify and save the document
    fruit.name = "Lemon";
    fruit.amount++;
    fruit.save();
    console.log(Fruits.getById("12345678912345678", true)); // { id: "12345678912345678", name: "Lemon", amount: 3 }
  • PageBuilder allows you to create a pagination.

    import { PageBuilder } from "@wave-dev/plugins";
    const fruits = [
      { name: "Apple", amount: 1 },
      { name: "Lemon", amount: 3 },
      { name: "Melon", amount: 6 },
    ];
    const pagination = new PageBuilder<{ name: string; amount: number },
      .addValues(...fruits)
      .setLimit(1)
      .setDisplayFormat((value) => `${value.name} x${value.amount}`)
      .setSearchFormat((value) => `${value.name} x${value.amount} 👈`)
      .setEmptyMessage("There aren't any fruits in this page")
      .setUnfoundMessage("Unnable to find that fruit :c");
1.1.1

2 years ago

1.1.0

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18-dev23d

2 years ago

1.0.18-dev

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago