npm.io
1.0.2 • Published 4 years ago

mid-utils

Licence
ISC
Version
1.0.2
Deps
0
Size
8 kB
Vulns
0
Weekly
0

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

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'
      }
    ]
 */