@constasj/helper
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

node-helper

Some useful functions for Node.js development.

Functions

deduplicate(arr)

deduplicate the array.

import { deduplicate } from '@constasj/helper';

const arr = [1, 2, 2];
const darr = deduplicate(arr);

darr; // [1,2]

You can also use it like that:

import '@constasj/helper';

const arr = [1, 2, 2];
const darr = arr.deduplicate();

darr; // [1,2]

enumToArray(enum)

change an enum to an array.

import { enumToArray } from '@constasj/helper';

enum Example {
    CORAS,
    BEDIS,
    NEGA
}

const arr = enumToArray(Example);

arr; // ["CORAS","BEDIS","NEGA"]

done(onFullfilled,onRejected)

Add done() for Promise chain.

import { promise } from '@constasj/helper';

const pro = Promise.resolve(1);
promise.done(
    pro,
    (value) => value,
    (reason) => {
        throw reason;
    }
);

You can also use it like that:

import '@constasj/helper';

const pro = Promise.resolve(1).done(
    (value) => value,
    (reason) => {
        throw reason;
    }
);

Readme

Keywords

none

Package Sidebar

Install

npm i @constasj/helper

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

25.9 kB

Total Files

22

Last publish

Collaborators

  • constasj