@douglasneuroinformatics/libjs 0.0.2 → 0.0.3
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/dist/string.d.ts +2 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +6 -0
- package/dist/string.test.js +15 -1
- package/package.json +15 -10
package/dist/string.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CamelCase, SnakeCase } from 'type-fest';
|
|
2
2
|
export declare function camelToSnakeCase<T extends string>(s: T): SnakeCase<T>;
|
|
3
3
|
export declare function snakeToCamelCase<T extends string>(s: T): CamelCase<T>;
|
|
4
|
+
export declare function uncapitalize<T extends string>(s: T): Uncapitalize<T>;
|
|
5
|
+
export declare function capitalize<T extends string>(s: T): Capitalize<T>;
|
|
4
6
|
//# sourceMappingURL=string.d.ts.map
|
package/dist/string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,gBAEtD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,gBAItD"}
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,gBAEtD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,gBAItD;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,mBAElD;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,iBAEhD"}
|
package/dist/string.js
CHANGED
|
@@ -6,3 +6,9 @@ export function snakeToCamelCase(s) {
|
|
|
6
6
|
.toLowerCase()
|
|
7
7
|
.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', ''));
|
|
8
8
|
}
|
|
9
|
+
export function uncapitalize(s) {
|
|
10
|
+
return (s.charAt(0).toLowerCase() + s.slice(1));
|
|
11
|
+
}
|
|
12
|
+
export function capitalize(s) {
|
|
13
|
+
return (s.charAt(0).toUpperCase() + s.slice(1));
|
|
14
|
+
}
|
package/dist/string.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { camelToSnakeCase, snakeToCamelCase } from './string.js';
|
|
2
|
+
import { camelToSnakeCase, capitalize, snakeToCamelCase, uncapitalize } from './string.js';
|
|
3
3
|
describe('camelToSnakeCase', () => {
|
|
4
4
|
it('should convert from camel to snake case ', () => {
|
|
5
5
|
expect(camelToSnakeCase('toSnakeCase')).toBe('to_snake_case');
|
|
@@ -14,3 +14,17 @@ describe('snakeToCamelCase', () => {
|
|
|
14
14
|
expect(camelToSnakeCase('')).toBe('');
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
+
describe('capitalize', () => {
|
|
18
|
+
it('should convert the first letter of the string to a capital letter', () => {
|
|
19
|
+
expect(capitalize('foo')).toBe('Foo');
|
|
20
|
+
expect(capitalize('FOO')).toBe('FOO');
|
|
21
|
+
expect(capitalize('foo bar')).toBe('Foo bar');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('uncapitalize', () => {
|
|
25
|
+
it('should convert the first letter of the string to a lowercase letter', () => {
|
|
26
|
+
expect(uncapitalize('Foo')).toBe('foo');
|
|
27
|
+
expect(uncapitalize('foo')).toBe('foo');
|
|
28
|
+
expect(uncapitalize('Foo bar')).toBe('foo bar');
|
|
29
|
+
});
|
|
30
|
+
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douglasneuroinformatics/libjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"packageManager": "pnpm@8.15.3",
|
|
6
6
|
"description": "A collection of utility functions and types for Node.js and the browser",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Douglas Neuroinformatics",
|
|
9
|
+
"email": "support@douglasneuroinformatics.ca"
|
|
10
|
+
},
|
|
7
11
|
"license": "LGPL-3.0",
|
|
8
12
|
"homepage": "https://github.com/DouglasNeuroInformatics/libjs/#readme",
|
|
9
13
|
"repository": {
|
|
@@ -18,14 +22,6 @@
|
|
|
18
22
|
"files": [
|
|
19
23
|
"dist"
|
|
20
24
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
23
|
-
"build:docs": "typedoc",
|
|
24
|
-
"format": "prettier --write src",
|
|
25
|
-
"lint": "tsc --noEmit && eslint --fix src",
|
|
26
|
-
"test": "vitest run",
|
|
27
|
-
"test:coverage": "vitest run --coverage"
|
|
28
|
-
},
|
|
29
25
|
"peerDependencies": {
|
|
30
26
|
"typescript": "^5.1.0"
|
|
31
27
|
},
|
|
@@ -36,9 +32,18 @@
|
|
|
36
32
|
"@douglasneuroinformatics/eslint-config": "^4.0.0",
|
|
37
33
|
"@vitest/coverage-v8": "^1.3.1",
|
|
38
34
|
"eslint": "^8.57.0",
|
|
35
|
+
"husky": "^9.0.11",
|
|
39
36
|
"prettier": "^3.2.5",
|
|
40
37
|
"typedoc": "^0.25.2",
|
|
41
38
|
"typescript": "~5.3.3",
|
|
42
39
|
"vitest": "^1.3.1"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"build:docs": "typedoc",
|
|
44
|
+
"format": "prettier --write src",
|
|
45
|
+
"lint": "tsc --noEmit && eslint --fix src",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:coverage": "vitest run --coverage"
|
|
43
48
|
}
|
|
44
|
-
}
|
|
49
|
+
}
|