@vicoders/support

2.0.13 • Public • Published

Vicoders Supporter Package

Collection of javascript utility functions.

Installation

Using npm

npm install @vicoders/support

Using yarn

yarn add @vicoders/support

Functions & Services

Notification

The notification library

// Partial import
import Notification from '@vicoders/support/services/Notification';
// Or you can do like this
// import { Notification } from '@vicoders/support/services';

Notification.show('success', 'This is a successed message and it will display for 3000 ms', 3000); // show the loader
Notification.show('success', 'This one display forever until you remove it');
Notification.show('warning', 'ALERT!!!'); // and the warning type
Notification.remove(); // hide the notification

Loader

The loading animation

// partial import
import Loader from '@vicoders/support/services/Loader';
// Or you can do like this
// import { Loader } from '@vicoders/support/services';

Loader.show(); // show the loader
Loader.hide(); // hide the loader

Sharing

Share content to social media

// partial import
import { Facebook } from '@vicoders/support/services/Social/Sharing/Facebook/Facebook';
// Or you can do like this
import { Facebook } from '@vicoders/support/services/Social/Sharing';

const fb = new Facebook({ appId: YOUR_FB_APP_ID });
fb.share({ href: 'https://example.com' });

// or share current page

fb.share({ href: document.location.href });

Anchor

Jump to element smooth

// partial import
import { Anchor } from '@vicoders/support/services/Anchor';
// Or you can do like this
import { Anchor } from '@vicoders/support/services';

const anchor = new Anchor();

anchor.jump('#element-id');

// anchor.jump('.element-class');
// anchor.jump('element-tag');

Utils

getRandomArbitrary

Returns a random number between min (inclusive) and max (exclusive)

import { Utils } from '@vicoders/support/services';

const r = Utils.getRandomArbitrary(1, 10);

random

Returns a random integer between min (inclusive) and max (inclusive).

  • The value is no lower than min (or the next integer greater than min
  • if min isn't an integer) and no greater than max (or the next integer
  • lower than max if max isn't an integer).
  • Using Math.round() will give you a non-uniform distribution!
import { Utils } from '@vicoders/support/services';

const r = Utils.random(1, 10);

findRandom

Find a random element of an array

import { Utils } from '@vicoders/support/services';

const r = Utils.findRandom([1, 2, 3, 4, 5, 6, 7], item => item % 2);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.13
    0
    • latest

Version History

Package Sidebar

Install

npm i @vicoders/support

Weekly Downloads

0

Version

2.0.13

License

MIT

Unpacked Size

1.25 MB

Total Files

45

Last publish

Collaborators

  • dunghoang103
  • nightfury
  • lebaotrung
  • khanhvuht