Skip to content

Commit

Permalink
readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufshakeel committed Mar 14, 2020
1 parent a12a363 commit 2096955
Showing 1 changed file with 61 additions and 12 deletions.
73 changes: 61 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is a simple coupon creation project using NodeJS.

[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/yusufshakeel/couponjs)
[![npm version](https://img.shields.io/badge/npm-0.3.0-blue.svg)](https://www.npmjs.com/package/couponjs)
[![npm version](https://img.shields.io/badge/npm-0.4.0-blue.svg)](https://www.npmjs.com/package/couponjs)
[![Build Status](https://travis-ci.com/yusufshakeel/couponjs.svg?branch=master)](https://travis-ci.com/yusufshakeel/couponjs)

# Getting Started
Expand All @@ -11,12 +11,6 @@ Add this to your project using npm.
> npm i couponjs
```

## Tests
Test code of this project is inside the `tests` directory.

Using the following for testing:
* Jest

## Generate coupon
Create an object of Coupon.
```javascript
Expand All @@ -32,7 +26,7 @@ const myCoupon = coupon.generate();

By default, `generate` will return coupon code of length 6 using uppercase alphabet.

### Coupon of length N
## Coupon of length N
To generate coupon of a given length we pass the following option to the `generate` method.
```javascript
const myCoupon = coupon.generate({
Expand All @@ -47,7 +41,7 @@ Range of `length`:

If length is not passed then default value of 6 is considered.

### Coupon with prefix
## Coupon with prefix
To generate a coupon with a given prefix we pass the following option to the `generate` method.
```javascript
const myCoupon = coupon.generate({
Expand All @@ -69,7 +63,7 @@ const myCoupon = coupon.generate({
```
We will get coupon like the following `SUPERAAA`.

### Coupon with suffix
## Coupon with suffix
To create coupon with suffix pass the following option.
```javascript
const myCoupon = coupon.generate({
Expand All @@ -79,9 +73,9 @@ const myCoupon = coupon.generate({
```
The above code will generate coupon like the following `ZZZAWESOME`.

Note! Characters of the suffix is not counted. If length is note specified then default value of 6 is considered as the length.
Note! Characters of the suffix is not counted. If length is not specified then default value of 6 is considered as the length.

### Coupon with prefix and suffix
## Coupon with prefix and suffix
To create coupon with prefix and suffix pass the following option.
```javascript
const myCoupon = coupon.generate({
Expand All @@ -94,6 +88,61 @@ The above code will generate coupon like the following `SUPERZZZZZZAWESOME`.

Note! The characters of the prefix and suffix is not considered. If length is not specified then default value of 6 is considered.

## Coupon with builtIn characterSet
To create coupon code with builtIn characterSet pass the following option.
```javascript
const myCoupon = coupon.generate({
characterSet: {
builtIn: ['charSetName']
}
});
```
Where, `charSetName` is any one of the following names.

- `CHARSET_ALPHA` -- which consists of uppercase alphabet characters A-Z
- `CHARSET_ALPHA_LOWER` -- which consists of lowercase alphabet characters a-z
- `CHARSET_DIGIT` -- which consists of digits 0-9

Example: If we want uppercase and digit we can pass the following.
```javascript
const myCoupon = coupon.generate({
characterSet: {
builtIn: ['CHARSET_ALPHA', 'CHARSET_DIGIT']
}
});
```

## Coupon with custom characterSet
To use custom characters to generate coupons pass the following option.
```javascript
const myCoupon = coupon.generate({
characterSet: {
custom: ['customChar']
}
});
```
Where, `customChar` is any custom characters that you wish to use.

Example: To use `ABC`, `xyz` and `01234` in coupon pass the following.
```javascript
const myCoupon = coupon.generate({
characterSet: {
custom: ['ABC', 'xyz', '01234']
}
});
```

## Coupons using builtIn and custom characterSet
Example: Following option will use digit `0-9` and alphabet `ABC`.
```javascript
const myCoupon = coupon.generate({
characterSet: {
builtIn: ['CHARSET_DIGIT'],
custom: ['ABC']
}
});
```

## License
It's free :smiley:

Expand Down

0 comments on commit 2096955

Please sign in to comment.