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

args-any

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

args-any

Utility lib for parsing command options

  • 1.4.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

args-any

Utility lib for parsing command options

Build Status Codacy Badge Coverage Status tested with jest code style: prettier David GitHub npm

Installation

npm install args-any

Test

npm test

Usage

Parse arguments to a map

import { parse } from "args-any";
const args = ["-option1", "value1", "-option2>4", "-option3 lt 5"]

const options = parse(args);

options.has("option1");
==> true

options.get("option2");
==> {
  key: "option2",
  operator: Operator.Gt,
  value: "4"
}

Map arguments to a partial type

import { parse } from "args-any";

const args = ["-name", "server 1", "-memorySize", "1024" , "-isClustered", "true"];

interface Server {
  name: string;
  memorySize: number;
  isClustered: boolean;
  location: string;
}

const server = parse(args).asPartial<Server>();

==> {
  name: "server 1",
  memorySize: 1024,
  isClustered: true
};

Filter a list based on arguments

const servers = [{
  name: "name 1",
  memorySize: 2048
}, {
  name: "name 2",
  memorySize: 2048
}, {
  name: "name 3",
  memorySize: 512
}];

const filtered = parse(["-memorySize=2048"]).filter(...servers);

==> [{
  name: "name1"
  ...
}, {
  name: "name2"
  ...
}
]

Keywords

FAQs

Package last updated on 19 Jun 2023

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