nexus-migration-validator-thomasin 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.
Files changed (3) hide show
  1. package/README.md +34 -0
  2. package/index.js +42 -0
  3. package/package.json +26 -0
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @your-scope/hello-utils
2
+
3
+ A simple utility library — sample npm package.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @your-scope/hello-utils
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ const { greet, titleCase, clamp } = require('@your-scope/hello-utils');
15
+
16
+ console.log(greet('Alice')); // Hello, Alice!
17
+ console.log(titleCase('hello world')); // Hello World
18
+ console.log(clamp(15, 0, 10)); // 10
19
+ ```
20
+
21
+ ## API
22
+
23
+ ### `greet(name: string): string`
24
+ Returns a greeting for the given name.
25
+
26
+ ### `titleCase(str: string): string`
27
+ Capitalizes the first letter of each word.
28
+
29
+ ### `clamp(value, min, max): number`
30
+ Clamps a number between `min` and `max` (inclusive).
31
+
32
+ ## License
33
+
34
+ MIT
package/index.js ADDED
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Returns a greeting string for the given name.
5
+ * @param {string} name
6
+ * @returns {string}
7
+ */
8
+ function greet(name) {
9
+ if (!name || typeof name !== 'string') {
10
+ throw new TypeError('name must be a non-empty string');
11
+ }
12
+ return `Hello, ${name}!`;
13
+ }
14
+
15
+ /**
16
+ * Capitalizes the first letter of each word in a string.
17
+ * @param {string} str
18
+ * @returns {string}
19
+ */
20
+ function titleCase(str) {
21
+ if (typeof str !== 'string') {
22
+ throw new TypeError('input must be a string');
23
+ }
24
+ return str
25
+ .toLowerCase()
26
+ .split(' ')
27
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
28
+ .join(' ');
29
+ }
30
+
31
+ /**
32
+ * Clamps a number between min and max (inclusive).
33
+ * @param {number} value
34
+ * @param {number} min
35
+ * @param {number} max
36
+ * @returns {number}
37
+ */
38
+ function clamp(value, min, max) {
39
+ return Math.min(Math.max(value, min), max);
40
+ }
41
+
42
+ module.exports = { greet, titleCase, clamp };
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "nexus-migration-validator-thomasin",
3
+ "version": "1.0.0",
4
+ "description": "A simple utility library — sample npm package",
5
+ "main": "index.js",
6
+ "exports": {
7
+ ".": "./index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "node test.js"
11
+ },
12
+ "keywords": [
13
+ "utility",
14
+ "sample",
15
+ "hello"
16
+ ],
17
+ "author": "thomasin33 <thomasin33>",
18
+ "license": "MIT",
19
+ "files": [
20
+ "index.js",
21
+ "README.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=14.0.0"
25
+ }
26
+ }