Nibbling Pastry Monster

    @pepijn98/kitai
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    Discord Version Downloads Dependencies Dev Dependencies Maintainability

    kitai (期待)

    This is a copy of kotlin's require function.
    It validates the condition you give it and if it's false will throw an IllegalArgumentException.

    Installation

    • npm i -S @pepijn98/kitai
    • yarn add @pepijn98/kitai

    Examples

    See examples for more

    // You can name this anything you want, I like "expect" since it fits the package name.
    // You can even name it require just like kotlin (only if you don't use node's require function)
    import expect from "@pepijn98/kitai";
    
    function test(arg: number): void {
        expect(arg >= 0, () => `"arg" cannot be a negative number, was ${arg}`);
        
        // We now know that arg will not be a negative number
        // Do your extremly complex 9000 IQ mathematical equation here
    }
    
    test(-5); // Will throw an IllegalArgumentException
    test(15); // Won't throw, yaay

    Name

    Since it's a Japanese name I guess I should explain this, even though I don't speak Japanese and use translators.
    Kitai written as 期待 in kanji, roughly means "Expectations" or "Expectation"

    (directly taken from google translate and deepl, please excuse my ignorance if it's completly wrong)

    Install

    npm i @pepijn98/kitai

    DownloadsWeekly Downloads

    1

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    50.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • kurozero