New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

argument-options

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

argument-options

argument options tool

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

argument-options

argument options tool

Install

npm install argument-options

Usage & Api

var argument_options = require("argument-options");

done(!(
	/*
	for function like func( ..., options )

	argumentOptions(options [, shortcutMapping | shortcutName [, defaultProperties ]] )

		shortcutMapping
			an object mapping typeof-string to shortcut property name;
				or to a function like func(options) that return another options;
		
		shortcutName
			a user-defined shortcut name string, usually a checking result from the caller process;

		defaultProperties:
			the default properties;
			if the defaultProperties is not empty, and the `options` is not an object after the shortcut processing,
				a _raw_options property will be added to the result;

	return a new options, or the original `options`, or the `defaultProperties`;
	*/

	cmp_json(argument_options("a"), "a") &&
	cmp_json(argument_options("a", { "string": "bb" }), { bb: "a" }) &&
	cmp_json(argument_options("a", { "number": "bb" }), "a") &&
	cmp_json(argument_options(123, { "number": "bb" }), { bb: 123 }) &&

	cmp_json(argument_options(null, { "object": "bb" }), { bb: null }) &&
	cmp_json(argument_options({ a: 1 }, { "object": "bb" }), { bb: { a: 1 } }) &&

	cmp_json(argument_options({ a: 1 }, { "object": o => o ? o : 1 }), { a: 1 }) &&
	cmp_json(argument_options(null, { "object": o => o ? o : 1 }), 1) &&

	cmp_json(argument_options({ a: 1 }, null, { a: 2 }), { a: 1 }) &&
	cmp_json(argument_options({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 }) &&

	cmp_json(argument_options("a", { "number": "bb" }, {}), { _raw_options: "a" }) &&
	cmp_json(argument_options(void 0, { "number": "bb" }, {}), {}) &&
	cmp_json(argument_options(null, { "number": "bb" }, {}), {}) &&
	cmp_json(argument_options(0, { "number": "bb" }, {}), { bb: 0 }) &&
	cmp_json(argument_options(0, { "string": "bb" }, {}), { _raw_options: 0 }) &&
	cmp_json(argument_options(false, { "number": "bb" }, {}), { _raw_options: false }) &&
	cmp_json(argument_options("", { "number": "bb" }, {}), { _raw_options: "" }) &&

	cmp_json(argument_options([1],
		{ "object": o => { if (o instanceof Array) return { arr: o }; } }, {}), { arr: [1] }) &&
	cmp_json(argument_options({ a: 1 },
		{ "object": o => { if (o instanceof Array) return { arr: o }; } }, {}), { a: 1 }) &&
	cmp_json(argument_options(null,
		{ "object": o => { if (o instanceof Array) return { arr: o }; } }, {}), {}) &&
	cmp_json(argument_options(null,
		{ "object": o => { if (o instanceof Array) return { arr: o }; } }), null) &&

	cmp_json(argument_options(o1, typeof o1 === "string" && "a"), o1) &&
	cmp_json(argument_options(o2, typeof o2 === "string" && "a"), { a: o2 }) &&
	cmp_json(argument_options(o1, typeof o1 === "number" && "b"), { b: o1 }) &&
	cmp_json(argument_options(o2, typeof o2 === "number" && "b"), o2) &&

	cmp_json(argument_options(o1,
		(typeof o1 === "string" && "a") || (typeof o1 === "number" && "b")), { b: o1 }) &&
	cmp_json(argument_options(o2,
		(typeof o2 === "string" && "a") || (typeof o2 === "number" && "b")), { a: o2 }) &&

	true
));

Keywords

arguments

FAQs

Package last updated on 02 Aug 2022

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