# auxiliary-js

> Auxiliary JS : a utility library ================================================================== Installation:

Latest version **2.0.0** (published 2017-04-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install auxiliary-js
pnpm add auxiliary-js
yarn add auxiliary-js
bun add auxiliary-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-04-14 |
| First published | 2017-04-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mujib517 |

## Links

- npm: https://www.npmjs.com/package/auxiliary-js
- npm.io page: https://npm.io/package/auxiliary-js

## Recent versions

- 2.0.0 (latest) — 2017-04-14
- 1.0.0 — 2017-04-14

## README

Auxiliary JS : a utility library 
==================================================================
<h4>Installation:<h4>

npm install auxiliary-js

<h4>Usage:</h4>

var util=require('util');

1. Each(): to iterate through an array or object

<pre>
    var list=[1,2,3];  // var list={"one":1,"two":2,"three":3};
    
    util.each(list,function(val){
        console.log(val);
    });

</pre>

2. Map(): to modify values of an object or array and return it.

<pre>
    var list=[1,2,3];

    util.map(list,functio(val){
        return val*2;
    });
</pre>

3. First() and Last() to get the first and last element from the list respectively.

<pre>
    var first=util.map([1,2,3]);
    var last=util.map([1,2,3]);
</pre>

4. Find(): returns the first matching elements from the array

<pre>
    var list=[1,2,3,4,5,6];
    var result=util.find(list,function(val){
        return val%2==0;
    });  //returns 2
</pre>

5. Filter(): returns all matching elements from the array

<pre>
    var list=[1,2,3,4,5,6];
    var result=util.filter(list,function(val){
        return val%2==0;
    });  //returns [2,4,6]
</pre>

6. Except(): returns all the non matching elements from the array

<pre>
    var list=[1,2,3,4,5,6];
    var result=util.excpt(list,function(val){
        return val%2==0;
    });  //returns [1,3,5]
</pre>

6. All(): returns true if all the  elements match the given criteria

<pre>
    var list=[2,4,6];
   var result = util.all(list, function (val) {
                return val % 2 == 0;
            });  //returns true;
</pre>

7. Any(): returns true if any of the elements match the given criteria

<pre>
    var list=[2,4,6];
    var result = util.any(list, function (val) {
                return val % 2 == 0;
   });  //returns true;
</pre>

8. Min() and Max(): returns min and max value from array respectively

<pre>
    var list=[2,4,6,-2];
    var min = util.min(list); //returns -2;
    var max = util.max(list); //returns 6;
</pre>

9. Sort(): to sort collections

<pre>
     var list = [2, 5, 1, 10, 8, 7];
     var result = util.sortBy(list); 
     
     var list = [
                { id: 2, name: "abc", price: 100 },
                { id: 5, name: "ghi", price: 200 },
                { id: 1, name: "def", price: 300 }
            ];
     var result = util.sort(list, "id"); //sorting by id field
</pre>

10. SortByDesc(): to sort collections in descending order

<pre>
     var list = [2, 5, 1, 10, 8, 7];
     var result = util.sortByDesc(list); 
     
     var list = [
                { id: 2, name: "abc", price: 100 },
                { id: 5, name: "ghi", price: 200 },
                { id: 1, name: "def", price: 300 }
            ];
     var result = util.sortByDesc(list, "id"); //sorting by id field
</pre>

11. Count(): to get the count of the elements satisfying the criteria

<pre>
     var list = [2, 5, 1, 10, 8, 7];
     var result = util.count(list,function(val){
         return val%2==0;
     }); //returns 3
     
</pre>

12. CountBy(): to get the count of the elements by their types

<pre>
    var list = [2, 3, 4, 5, 6, 7, 0, 0, 8, 0];

    var result = util.countBy(list, function (val) {
        if (val == 0) return 'zero';
        if (val % 2 == 0) return 'even';
        return 'odd';
    });

   /*
   returns 
   {
        zero: 3,
        even: 4,
        odd: 3
    }
    */
</pre>

---
_Source: https://npm.io/package/auxiliary-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
