2.0.4 • Published 2 years ago

m19wq922 v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Information

name :              m19wq922
author :            91d906h4
version :           2.0.4
description :       This npm package provide some common js functions.
main :              index.js
license :           MIT
registry :          https://registry.npmjs.org/

Installation

npm install m19wq922

And import m19wq922 with the following line :

var m19wq922 = require("m19wq922");

Functions

1.Random string generator

m19wq922.rand(STRING, LENGTH);

This function is used to generate a random string. The variable "LENGTH" determines the length of random string, and the variable "STRING" determines the element of the string. For example :

m19wq922.rand("abcdefghijklmnopqrstuvwxyz", 8);

This line will generate a string that has 8 characters that includes a to z.

And you can also use "aA0!", "aA0", "aA", "A0", or "a0" to determine the characters that you want to use in the random string.

"aA0!" includes "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?#$%&'()[]{}*+-/.,:<>=@~". "aA0" includes "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". "aA" includes "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ". "A0" includes "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". "a0" includes "abcdefghijklmnopqrstuvwxyz0123456789". "A" includes "ABCDEFGHIJKLMNOPQRSTUVWXYZ". "a" includes "abcdefghijklmnopqrstuvwxyz".

Otherwise, you can use "0" to generate a random number. For example :

m19wq922.rand("0", 8);

This line will generate a 8-length random number. Variable "LENGTH" must be a number and variable "STRING" must be a string.

2.Get sum of array

m19wq922.sum(ARRAY);

This function is used to get the sum of array. For example :

m19wq922.sum([0, 1, 2, 3, 4, 5]);

This line will return number 15 (0 + 1 + 2 + 3 + 4 + 5), and the following lines will return string becuse there are strings in the array :

m19wq922.sum([0, 1, 2, 3, 4, "5"]); // return "012345"
m19wq922.sum([0, 1, 2, 3, 4, "a"]); // return "01234a"

The variable "ARRAY" must be an array.

3.Remove element from array

m19wq922.remove(ARRAY, ELEMENT);

This function is used to remeove element form an array. The variable "ELEMENT" determines the element you want to remove from "ARRAY". The variable "ARRAY" must be an array.

4.Sort array

m19wq922.sort(ARRAY[, true/false]);

This function is used to sort array by value. The option true/false determine the order is in order or reverse. The default value is true.

5.Regular expression

m19wq922.regex(STRING, RULE);

This function is used to check if variable "STRING" is match to the regular expression. And you can use the following rules : "email", "url", "ip", "date", "number" and "text". Also, you can just enter your custom rule.

6.Get cookie

m19wq922.getcookie(COOKIE);

This function is used to get the cookie from browser. The variable "COOKIE" determines the name of cookie you want. Variable "COOKIE" must be a string.

1.0.19

2 years ago

1.0.38

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

2.0.1

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago