Skip to content

Commit

Permalink
Merge 370d96b into 2f0d957
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Apr 15, 2019
2 parents 2f0d957 + 370d96b commit f8cdc59
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 90 deletions.
1 change: 1 addition & 0 deletions docs/credit-card-gaps-pattern.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 0 additions & 72 deletions docs/credit-card-gasp-pattern.js

This file was deleted.

4 changes: 3 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1>Credit card</h1>


<script src="restricted-input.js"></script>
<script src="../lib/credit-card-gaps-pattern.js"></script>
<script src="credit-card-gaps-pattern.js"></script>
<script>
const element = document.querySelector('input');
const data = {
Expand All @@ -108,10 +108,12 @@ <h1>Credit card</h1>
formattedCreditCardInput.setPattern(creditCardGapsPattern(data.unionpay.gaps, data.unionpay.lengths));

function setUnionpay() {
element.value = data.unionpay.value;
formattedCreditCardInput.setPattern(creditCardGapsPattern(data.unionpay.gaps, data.unionpay.lengths));
}

function setAmex() {
element.value = data.amex.value;
formattedCreditCardInput.setPattern(creditCardGapsPattern(data.amex.gaps, data.amex.lengths));
}
</script>
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@
"eslint-plugin-markdown": "^1.0.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-require-path-exists": "^1.1.5",
"eslint-plugin-unicorn": "^8.0.1",
"eslint-plugin-unicorn": "^8.0.2",
"husky": "^1.3.1",
"lint-staged": "^8.1.1",
"nyc": "^13.1.0",
"prettier": "^1.16.4",
"prettier": "^1.17.0",
"read-pkg": "^5.0.0",
"rimraf": "^2.6.3",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-terser": "^4.0.3"
},
"husky": {
Expand Down
9 changes: 8 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ import readPkg from 'read-pkg'
import camelCase from 'camelcase';
import babel from 'rollup-plugin-babel';
import { terser } from "rollup-plugin-terser";
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import builtins from 'rollup-plugin-node-builtins';

const {name} = readPkg.sync()

export default {
input: 'src/index.js',
output: [
{ file: 'lib/index.js', format: 'cjs' },
{ file: `lib/${name}.js`, format: 'iife', name: `${camelCase(name)}` }
{ file: `lib/${name}.js`, format: 'iife', name: `${camelCase(name)}` },
{ file: `docs/${name}.js`, format: 'iife', name: `${camelCase(name)}` }
],
plugins: [
resolve(),
commonjs(),
builtins(),
babel({
plugins: [],
presets: [
Expand Down
13 changes: 13 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
type: {
DIGIT: 9
},
errors: {
GAPS_MISSING: 'A gaps option must be provided',
GAPS_NOT_ARRAY: 'A gaps option must be Array',
GAPS_NOT_EMPTY: 'A gaps option must not be empty',
LENGTHS_MISSING: 'A lengths option must be provided',
LENGTHS_NOT_ARRAY: 'A lengths option must be Array',
LENGTHS_NOT_EMPTY: 'A lengths option must not be empty'
}
};
14 changes: 1 addition & 13 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
export const constants = {
type: {
DIGIT: 9
},
errors: {
GAPS_MISSING: 'A gaps option must be provided',
GAPS_NOT_ARRAY: 'A gaps option must be Array',
GAPS_NOT_EMPTY: 'A gaps option must not be empty',
LENGTHS_MISSING: 'A lengths option must be provided',
LENGTHS_NOT_ARRAY: 'A lengths option must be Array',
LENGTHS_NOT_EMPTY: 'A lengths option must not be empty'
}
};
import constants from './constants';

export default (gaps, lengths, type = 'DIGIT') => {
if (gaps === undefined) {
Expand Down
3 changes: 2 additions & 1 deletion test/test-throws.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'ava';
import creditCardGapsPattern, {constants} from '../src';
import constants from '../src/constants';
import creditCardGapsPattern from '../src';

test('gaps option must be provided', t => {
const {message} = t.throws(creditCardGapsPattern);
Expand Down

0 comments on commit f8cdc59

Please sign in to comment.