0.5.5 • Published 2 years ago

inadequado v0.5.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

For the most part this package is for personal use, but you can use it too :)

Version License

Currently implemented: LocalStorage KeyTracking Prototypes Tools

Already done, but no instructions.

WebObserver


namespace LocalStorage

Allows you to use LocalStorage conveniently.

Examples

LocalStorage.setItem("key", 1);
LocalStorage.getItem("key"); // 1 (number)

LocalStorage.setItem("key", "1");
LocalStorage.getItem("key"); // "1" (string)

LocalStorage.setItem("key", { a: "A" });
LocalStorage.getItem("key"); // { a: "A" } (object)

class A {}
LocalStorage.setItem("key", { a: new A() });
LocalStorage.getItem("key"); // { a: {} } (object)

In the case of class A {}, the information that it is an instance of class A will be lost when the object is received.

Types

type localStorageTypes = number | string | (number | string[]) | object;
export function getItem<T extends localStorageTypes>(key: string): T | null;

export function setItem(key: string, value: localStorageTypes): void;

namespace KeyTracking

Helps you keep track of keystrokes and perform functions when certain combinations are pressed.

Examples

KeyTracking.createCombination("KeyH", () => console.log("Hello"));

KeyTracking.createCombination(["ControlLeft", "KeyS"], () => console.log("Save"));


KeyTracking.deleteCombination(["ControlLeft", "KeyS"]);

It is not recommended to create combinations of more than 3 keys.


namespace Prototypes

Expansion for primitive types

How to use

import { Prototypes } from "inadequado/dist/Tools";

Prototypes.Array();
Prototypes.String();
// ... OR ...
Prototypes.All();

List of new methods for String:

/** Removes HTML tags from the string */
stripTags(): this;
/** Converts special characters into HTML entities */
htmlspecialchars(remquotes?: boolean): this;

List of new methods for Array:

/** Shuffle the array */
shuffle(): T[];
/** Get random elements from an array.
 * @module Inadequado
 */
randomElements(count: number, prohibitRepetition?: boolean): T[];
randomElements(count?: 1): T;

Tools

Contains small and useful functionality

random(100, true) // 100%, be true
random(50, true) // 50%, be true | null,
random(0, true) // 0%, be null
randomRange(100, 500) // number from 100 to 500
0.5.5

2 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago