New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pepijn98/kitai

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pepijn98/kitai

Validate condition, specifically to check if a function argument is what you expected it to be

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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)

Keywords

FAQs

Package last updated on 20 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc