open-index/open-npm huggingface dataset:
npm package: @innotrade/enapso-args
Description: Enapso Smart Arguments Processor
Author: Alexander Schulze
Latest version: 1.0.1

# Enapso Smart Arguments Processor

You can either pass a single object as arguments or the arguments in the defined order.


## Why to use the Enapso Smart Arguments Processor?

You avoid unexpected results due to wrong or missing arguments or due to wrong argument order.
You can specify defaults for missing arguments and valdiate your arguments against a given schema.


## Installation
```
npm i @innotrade/enapso-args --save
```

## Usage

## Initialization
```javascript
const
    { EnapsoArguments } = require('@innotrade/enapso-args')
    ;

global.enargs = new EnapsoArguments();
global.enGetArgs = enargs.getArgs;
```

## Arg Validation Schema
```javascript
const
    schemaSingleStringArg = {
        args: [
            {
                "identifier": "text",
                "type": "string",
                "required": false,
                "default": "default value",
                "minLength": 0,
                "maxLength": 20
            }
        ]
    };
```
## Argument Validation
```javascript

function demoSingleStringArg(/*text*/) {
    let args = enGetArgs(arguments, schemaSingleStringArg, logValidationViolation);
    console.log('demoSingleStringArg: ' + args.text);
}

function demo() {
    demoSingleStringArg("Test");
    demoSingleStringArg(1);
    demoSingleStringArg(true);
    demoSingleStringArg();
}
```
## Output
```
demoSingleStringArg: Test
Error: Argument 'text' must be of type 'string' but is of type 'number'. Value: 1
demoSingleStringArg: 1
Error: Argument 'text' must be of type 'string' but is of type 'boolean'. Value: true
demoSingleStringArg: true
demoSingleStringArg: default value
```
npm package: @innotrade/enapso-js-tools
Description: ENAPSO JavaScript Toolbox
Author: Alexander Schulze
Latest version: 1.1.0

# enapso-js-tools

Enapso JavaScript Toolbox

Convenience methods for various classes, often used in ENAPSO.

# Installation

`npm i @innotrade/enapso-js-tools --save`

# Usage

```javascript
const { EnapsoJSTools } = require("@innotrade/enapso-js-tools");
```

## Convenience functions

### delay

If you want to provide certain convenience methods directly in the global namespace of your app like this:

```javascript
global.delay = EnapsoJSTools.delay;
```

you can use them easily like this:

```javascript
// async delay function
console.log("Delay 1000ms, started: " + new Date().toISOString());
await delay(1000);
console.log("Delay 1000ms, finished: " + new Date().toISOString());
```

If you prefer to not polute the global namespace, of course, you can also use:

```javascript
await EnapsoJSTools.delay(1000);
```

without the global.delay assignment.
Console Output

```
Delay 1000ms, started: 2020-02-01T10:17:14.087Z
Delay 1000ms, finished: 2020-02-01T10:17:15.089Z
```

## Extensions of JS Classes

### Array

Alternative for the often confusing splice method of the Array class:

```javascript
Array.prototype.insert(idx, item);
Array.prototype.delete(idx);
```