Skip to content

Commit 130f4df

Browse files
🎉
0 parents  commit 130f4df

File tree

11 files changed

+2973
-0
lines changed

11 files changed

+2973
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[{package.json,*.yml}]
11+
indent_style = space
12+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- 'node'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Tiaan <tiaanduplessis@hotmail.com> (tiaan.beer)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<h1 align="center">codebar-regex</h1>
2+
<div align="center">
3+
<strong>Regular expression for matching codebar barcode</strong>
4+
</div>
5+
<br>
6+
<div align="center">
7+
<a href="https://npmjs.org/package/codebar-regex">
8+
<img src="https://img.shields.io/npm/v/codebar-regex.svg?style=flat-square" alt="Package version" />
9+
</a>
10+
<a href="https://npmjs.org/package/codebar-regex">
11+
<img src="https://img.shields.io/npm/dm/codebar-regex.svg?style=flat-square" alt="Downloads" />
12+
</a>
13+
<a href="https://github.com/feross/standard">
14+
<img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square" alt="Standard" />
15+
</a>
16+
<a href="https://travis-ci.org/tiaanduplessis/codebar-regex">
17+
<img src="https://img.shields.io/travis/tiaanduplessis/codebar-regex.svg?style=flat-square" alt="Travis Build" />
18+
</a>
19+
<a href="https://github.com/RichardLitt/standard-readme)">
20+
<img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" alt="Standard Readme" />
21+
</a>
22+
<a href="https://badge.fury.io/gh/tiaanduplessis%2Fcodebar-regex">
23+
<img src="https://badge.fury.io/gh/tiaanduplessis%2Fcodebar-regex.svg?style=flat-square" alt="GitHub version" />
24+
</a>
25+
<a href="https://dependencyci.com/github/tiaanduplessis/codebar-regex">
26+
<img src="https://dependencyci.com/github/tiaanduplessis/codebar-regex/badge?style=flat-square" alt="Dependency CI" />
27+
</a>
28+
<a href="https://github.com/tiaanduplessis/codebar-regex/blob/master/LICENSE">
29+
<img src="https://img.shields.io/npm/l/codebar-regex.svg?style=flat-square" alt="License" />
30+
</a>
31+
<a href="http://makeapullrequest.com">
32+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs" />
33+
</a>
34+
<a href="https://www.paypal.me/tiaanduplessis/1">
35+
<img src="https://img.shields.io/badge/$-support-green.svg?style=flat-square" alt="Donate" />
36+
</a>
37+
</div>
38+
<br>
39+
<div align="center">
40+
<a href="https://github.com/tiaanduplessis/codebar-regex/watchers">
41+
<img src="https://img.shields.io/github/watchers/tiaanduplessis/codebar-regex.svg?style=social" alt="Github Watch Badge" />
42+
</a>
43+
<a href="https://github.com/tiaanduplessis/codebar-regex/stargazers">
44+
<img src="https://img.shields.io/github/stars/tiaanduplessis/codebar-regex.svg?style=social" alt="Github Star Badge" />
45+
</a>
46+
<a href="https://twitter.com/intent/tweet?text=Check%20out%20codebar-regex!%20https://github.com/tiaanduplessis/codebar-regex%20%F0%9F%91%8D">
47+
<img src="https://img.shields.io/twitter/url/https/github.com/tiaanduplessis/codebar-regex.svg?style=social" alt="Tweet" />
48+
</a>
49+
</div>
50+
<br>
51+
<div align="center">
52+
Built with ❤︎ by <a href="tiaan.beer">Tiaan</a> and <a href="https://github.com/tiaanduplessis/codebar-regex/graphs/contributors">contributors</a>
53+
</div>
54+
55+
<h2>Table of Contents</h2>
56+
<details>
57+
<summary>Table of Contents</summary>
58+
<li><a href="#install">Install</a></li>
59+
<li><a href="#usage">Usage</a></li>
60+
<li><a href="#cli">CLI</a></li>
61+
<li><a href="#contribute">Contribute</a></li>
62+
<li><a href="#license">License</a></li>
63+
</details>
64+
65+
## Install
66+
67+
```sh
68+
$ npm install --save codebar-regex
69+
# OR
70+
$ yarn add codebar-regex
71+
```
72+
73+
## Usage
74+
75+
```js
76+
77+
const codebarRegex = require('codebar-regex')
78+
79+
console.log(codebarRegex().test('A40156B')) // true
80+
81+
console.log(codebarRegex().test('A31117013206375B')) // true
82+
83+
```
84+
85+
86+
## CLI
87+
88+
```sh
89+
$ npm install --global codebar-regex
90+
# OR
91+
$ yarn global add codebar-regex
92+
```
93+
94+
Then:
95+
96+
```sh
97+
$ codebar A40156B
98+
# true
99+
```
100+
101+
## Contribute
102+
103+
Contributions are welcome. Please open up an issue or create PR if you would like to help out.
104+
105+
Note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
106+
107+
## License
108+
109+
Licensed under the MIT License.

cli.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
4+
const codebarRegex = require('./')
5+
const str = process.argv[2]
6+
7+
console.log(codebarRegex().test(str))

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict'
2+
3+
module.exports = function () {
4+
const pattern = `[A-D][0-9\\-\\$\\:\\.\\+\\/]+[A-D]`
5+
return new RegExp('^' + pattern + '$', 'g')
6+
}

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "codebar-regex",
3+
"version": "1.0.0",
4+
"description": "Regular expression for matching codebar barcode",
5+
"license": "MIT",
6+
"main": "index.js",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/tiaanduplessis/codebar-regex.git"
10+
},
11+
"homepage": "https://github.com/tiaanduplessis/codebar-regex",
12+
"bugs": "https://github.com/tiaanduplessis/codebar-regex/issues",
13+
"author": {
14+
"name": "Tiaan",
15+
"email": "tiaanduplessis@hotmail.com",
16+
"url": "tiaan.beer"
17+
},
18+
"bin": {
19+
"codebar": "cli.js"
20+
},
21+
"scripts": {
22+
"start": "npm run dev",
23+
"pretest": "npm run lint:fix",
24+
"test": "jest --env=node",
25+
"test:watch": "npm test -- --watch",
26+
"coverage": "npm test -- --coverage",
27+
"lint": "standard --verbose",
28+
"lint:fix": "standard --fix --verbose",
29+
"precommit": "npm test"
30+
},
31+
"keywords": [
32+
"regex",
33+
"regular-expression",
34+
"codebar",
35+
"barcode",
36+
"codebar-regex"
37+
],
38+
"dependencies": {},
39+
"devDependencies": {
40+
"husky": "^0.13.3",
41+
"jest": "^19.0.2",
42+
"standard": "^10.0.1"
43+
}
44+
}

test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-env jest */
2+
'use strict'
3+
4+
const codebarRegex = require('codebar-regex')
5+
6+
test('codebar-regex', () => {
7+
expect(codebarRegex().test('A40156B')).toBeTruthy()
8+
expect(codebarRegex().test('A31117013206375B')).toBeTruthy()
9+
expect(codebarRegex().test('foobarbaz')).toBeFalsy()
10+
})

0 commit comments

Comments
 (0)