Skip to content

[WIP] Cross-platform, general-purpose, JavaScript core library for Node, Deno and the browser. Can be used standalone, but is intended as a common dependency of @sv443-network/userutils and @sv443-network/djsutils

License

Notifications You must be signed in to change notification settings

Sv443-Network/CoreUtils

Repository files navigation

CoreUtils

Cross-platform, general-purpose, JavaScript core library for Node, Deno and the browser.
Intended to be used in conjunction with @sv443-network/userutils and @sv443-network/djsutils, but can be used independently as well.


Features

  • Misc. Types:
    • 🔷 type LooseUnion - A union type that allows for autocomplete suggestions as well as substitutions of the same type
    • 🔷 type ListLike - Any value with a quantifiable length, count or size property
    • 🔷 type Newable - Any class reference that can be instantiated with new
    • 🔷 type NonEmptyArray - Non-empty array type
    • 🔷 type NonEmptyString - String type with at least one character
    • 🔷 type NumberFormat - Number format identifier
    • 🔷 type Prettify - Makes the structure of a type more readable by fully expanding it (recursively)
    • 🔷 type SerializableVal - Any value that can be serialized to JSON
    • 🔷 type StringGen - A value that can be either of type string, or a sync or async function that returns a string
    • 🔷 type ValueGen - A value that can be either the generic type T, or a sync or async function that returns T
    • 🔷 type Stringifiable - Any value that can be implicitly converted to a string

Note

🟣 = function
🟧 = class
🔷 = type
🔶 = const


Installation

  • If you are using Node.js or Deno, install the package from NPM or JSR via your favorite package manager:
npm i @sv443-network/coreutils
pnpm i @sv443-network/coreutils
yarn add @sv443-network/coreutils
npx jsr install @sv443-network/coreutils
deno add jsr:@sv443-network/coreutils
  • If you are in a DOM environment, you can include the UMD bundle using your favorite CDN:
<script src="https://cdn.jsdelivr.net/npm/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
<script src="https://unpkg.com/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
<script src="https://esm.sh/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
  • Then, import parts of the library as needed:
// >> EcmaScript Modules (ESM):

// - import parts of the library:
import { randomItem } from "@sv443-network/coreutils";
// - or import the full library:
import * as CoreUtils from "@sv443-network/coreutils";
// - or import raw TS files, after installing via JSR:
import { DataStore } from "jsr:@sv443-network/coreutils/lib/DataStore.ts";

// >> CommonJS (CJS):

// - import parts of the library:
const { debounce } = require("@sv443-network/coreutils");
// - or import the full library:
const CoreUtils = require("@sv443-network/coreutils");

// >> Universal Module Definition (UMD):

// - to make the global variable `CoreUtils` available, import this file:
// "@sv443-network/coreutils/dist/CoreUtils.min.umd.js"
// - or import the library on your HTML page:
// <script src="https://cdn.jsdelivr.net/npm/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>

About

[WIP] Cross-platform, general-purpose, JavaScript core library for Node, Deno and the browser. Can be used standalone, but is intended as a common dependency of @sv443-network/userutils and @sv443-network/djsutils

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published