is-bract 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # is-bract
2
+
3
+ A simple npm package to test if a string contains the substring "bract".
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install is-bract
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```javascript
14
+ const isBract = require('is-bract');
15
+
16
+ console.log(isBract('I love bracts')); // true
17
+ console.log(isBract('Hello world')); // false
18
+ ```
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "is-bract",
3
+ "version": "1.0.0",
4
+ "description": "Returns true if the string contains the word 'bract'",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "node test/test.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/bract-tech/is-bract.git"
12
+ },
13
+ "keywords": [
14
+ "bract",
15
+ "is-bract",
16
+ "string",
17
+ "test"
18
+ ],
19
+ "author": {
20
+ "name": "Bract Technologies",
21
+ "email": "opensource@bract.tech",
22
+ "url": "https://bract.tech"
23
+ },
24
+ "contributors": [
25
+ {
26
+ "name": "Clitson Belleau",
27
+ "email": "clbe-c384@bract.tech"
28
+ }
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "bugs": {
32
+ "url": "https://github.com/bract-tech/is-bract/issues"
33
+ },
34
+ "homepage": "https://github.com/bract-tech/is-bract#readme",
35
+ "publishConfig": {
36
+ "tag": "latest",
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ }
40
+ }
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ function isBract(str) {
2
+ if (typeof str !== 'string') {
3
+ return false;
4
+ }
5
+ return str.includes('bract');
6
+ }
7
+
8
+ module.exports = isBract;
package/test/test.js ADDED
@@ -0,0 +1,31 @@
1
+ const isBract = require('../src/index');
2
+
3
+ const tests = [
4
+ { input: 'bract', expected: true },
5
+ { input: 'this is a bract', expected: true },
6
+ { input: 'bracts are cool', expected: true },
7
+ { input: 'Bract', expected: false },
8
+ { input: 'apple', expected: false },
9
+ { input: '', expected: false },
10
+ { input: null, expected: false },
11
+ ];
12
+
13
+ let allPassed = true;
14
+
15
+ tests.forEach((test, index) => {
16
+ const result = isBract(test.input);
17
+ if (result === test.expected) {
18
+ console.log(`Test ${index + 1} passed`);
19
+ } else {
20
+ console.error(`Test ${index + 1} failed: expected ${test.expected} for "${test.input}", got ${result}`);
21
+ allPassed = false;
22
+ }
23
+ });
24
+
25
+ if (allPassed) {
26
+ console.log('All tests passed!');
27
+ process.exit(0);
28
+ } else {
29
+ console.error('Some tests failed.');
30
+ process.exit(1);
31
+ }