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

@slimio/arg-checker

Package Overview
Dependencies
Maintainers
6
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slimio/arg-checker

SlimIO Argument Checker

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by18.18%
Maintainers
6
Weekly downloads
 
Created
Source

arg-checker

version Maintenance MIT

SlimIO Argument Checker. This package is inspired by ow to retrieve the callsites but doesn't include any built-in predicates.

Requirements

  • Node.js v10 or higher

Why ?

  • No built-in predicates/validation
  • No browser support (only Node.js).

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/arg-checker
# or
$ yarn add @slimio/arg-checker

Usage example

const argc = require("@slimio/arg-checker");
const is = require("@slimio/is");

function sayHello(name, age) {
    argc(name, [is.string, is.symbol]); // <-- Array stand for "OR" condition
    argc(age, is.number);
}

sayHello("fraxken", 24);
// => No error
sayHello(true);
// => ArgumentError: 'name' doesn't match his predicate(s)

API

argc(arg: any, ...predicates: (argc.predicate | argc.predicate[])[]): void

Check if arg match his predicates.

const logValidInput = (input) => {
    argc(input, is.number, (num) => num > 10 && num < 20);
    // ...predicates are executing as && condition.
    console.log(input);
}

logValidInput(15);
// => No Error

logValidInput(50);
// => ArgumentError: 'input' doesn't match his predicate(s)

Roadmap

  • Custom Error message ?
  • Improve predicates detection ?

Dependencies

NameRefactoringSecurity RiskUsage
callsites⚠️MajorLowGet V8 call stack traces
clean-stackMinorLowClean the stack trace generated by Errors

License

MIT

Keywords

FAQs

Package last updated on 19 Sep 2019

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