From 20969550da49681fe8cb34b2a13a89f570fae9d8 Mon Sep 17 00:00:00 2001 From: Yusuf Shakeel Date: Sat, 14 Mar 2020 14:57:00 +0530 Subject: [PATCH] readme updated --- README.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c8c8971..675f038 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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: