1.0.2 • Published 2 years ago
mid-utils v1.0.2
MID Utilities
For Member ID Projects
Requirements
For development, you will only need Node.js and a node global package, Yarn, installed in your environment.
Node
Node installation on Windows
Just go on official Node.js website and download the installer. Also, be sure to have
git
available in your PATH,npm
might need it (You can find git here).Node installation on Ubuntu
You can install nodejs and npm easily with apt install, just run the following commands.
$ sudo apt install nodejs $ sudo apt install npm
Other Operating Systems
You can find more information about the installation on the official Node.js website and the official NPM website.
If the installation was successful, you should be able to run the following command.
$ node --version
v15.14.0
$ npm --version
7.10.0
Installation
Use the package manager npm to install mid-utils.
npm install mid-utils
Usage
Array Helper
import { ArrayHelper } from 'mid-utils';
const arrayObject = [
{
id: 1,
name: 'Andy'
},
{
id: 2,
name: 'Tommy'
}
];
offset
console.log(ArrayHelper.offset(arrayObject, 0));
/**
* result
* [
{
id: 1,
name: 'Andy'
},
{
id: 2,
name: 'Tommy'
}
]
*/
console.log(ArrayHelper.offset(arrayObject, 1));
/**
* result
[
{
id: 2,
name: 'Tommy'
}
]
*/
limit
console.log(ArrayHelper.limit(arrayObject, 1));
/**
* result
* [
{
id: 1,
name: 'Andy'
}
]
*/
sort
console.log(ArrayHelper.sort(arrayObject, 'name', 'DESC'));
/**
* result
* [
{
id: 2,
name: 'Tommy'
},
{
id: 1,
name: 'Andy'
}
]
*/