@gkucmierz/utils 1.23.0 → 1.24.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/main.mjs +8 -4
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/spec/binary-search.spec.mjs +15 -0
- package/spec/copy-case.spec.mjs +12 -0
- package/src/{bisection-search.mjs → binary-search.mjs} +1 -1
- package/src/copy-case.mjs +12 -0
- package/src/matrix.mjs +1 -1
- package/spec/bisection-search.spec.mjs +0 -15
package/main.mjs
CHANGED
|
@@ -9,8 +9,11 @@ import {
|
|
|
9
9
|
bijective2num, bijective2numBI, num2bijective, num2bijectiveBI
|
|
10
10
|
} from './src/bijective-numeration.mjs'
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
} from './src/
|
|
12
|
+
binarySearchArr
|
|
13
|
+
} from './src/binary-search.mjs'
|
|
14
|
+
import {
|
|
15
|
+
copyCase
|
|
16
|
+
} from './src/copy-case.mjs'
|
|
14
17
|
import {
|
|
15
18
|
egcd
|
|
16
19
|
} from './src/egcd.mjs'
|
|
@@ -66,7 +69,8 @@ import {
|
|
|
66
69
|
export * from './src/SetCnt.mjs';
|
|
67
70
|
export * from './src/base64.mjs';
|
|
68
71
|
export * from './src/bijective-numeration.mjs';
|
|
69
|
-
export * from './src/
|
|
72
|
+
export * from './src/binary-search.mjs';
|
|
73
|
+
export * from './src/copy-case.mjs';
|
|
70
74
|
export * from './src/egcd.mjs';
|
|
71
75
|
export * from './src/factors.mjs';
|
|
72
76
|
export * from './src/gcd.mjs';
|
|
@@ -86,5 +90,5 @@ export * from './src/square-root.mjs';
|
|
|
86
90
|
export * from './src/tonelli-shanks.mjs';
|
|
87
91
|
|
|
88
92
|
export default [
|
|
89
|
-
SetCnt, fromBase64, fromBase64Url, toBase64, toBase64Url, bijective2num, bijective2numBI, num2bijective, num2bijectiveBI,
|
|
93
|
+
SetCnt, fromBase64, fromBase64Url, toBase64, toBase64Url, bijective2num, bijective2numBI, num2bijective, num2bijectiveBI, binarySearchArr, copyCase, egcd, factors, factorsBI, gcd, gcdBI, getType, gpn, gpnBI, Heap, heronsFormula, heronsFormulaBI, lcm, lcmBI, ListNode, matrixAsArray, memoize, mod, modBI, phi, phiBI, powMod, powModBI, array2range, range2array, squareRoot, squareRootBI, tonelliShanksBI
|
|
90
94
|
];
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gkucmierz/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@gkucmierz/utils",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.24.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"husky": "^8.0.1",
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
binarySearchArr,
|
|
4
|
+
} from '../src/binary-search.mjs';
|
|
5
|
+
|
|
6
|
+
describe('binarySearchArr', () => {
|
|
7
|
+
it('few cases', () => {
|
|
8
|
+
expect(binarySearchArr([1, 2, 3, 4], 1)).toBe(0);
|
|
9
|
+
expect(binarySearchArr([1, 2, 3, 4], 2)).toBe(1);
|
|
10
|
+
expect(binarySearchArr([1, 2, 3, 4], 3)).toBe(2);
|
|
11
|
+
expect(binarySearchArr([1, 2, 3, 4], 4)).toBe(3);
|
|
12
|
+
expect(binarySearchArr([1, 2, 3, 4], 0)).toBe(-1);
|
|
13
|
+
expect(binarySearchArr([1, 2, 3, 4], 5)).toBe(-1);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
copyCase,
|
|
4
|
+
} from '../src/copy-case.mjs';
|
|
5
|
+
|
|
6
|
+
describe('copy-case', () => {
|
|
7
|
+
it('few tests', () => {
|
|
8
|
+
expect(copyCase('styczeń', 'january')).toBe('styczeń');
|
|
9
|
+
expect(copyCase('styczeń', 'January')).toBe('Styczeń');
|
|
10
|
+
expect(copyCase('styczeń', 'JANUARY')).toBe('STYCZEŃ');
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export const copyCase = (word, from) => {
|
|
4
|
+
const isLower = w => w.toLowerCase() === w;
|
|
5
|
+
const isUpper = w => w.toUpperCase() === w;
|
|
6
|
+
if (isLower(from)) return word.toLowerCase();
|
|
7
|
+
if (isUpper(from)) return word.toUpperCase();
|
|
8
|
+
if (isUpper(from[0]) && isLower(from.slice(1))) {
|
|
9
|
+
return word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
return word;
|
|
12
|
+
};
|
package/src/matrix.mjs
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
bisectionSearchArr,
|
|
4
|
-
} from '../src/bisection-search.mjs';
|
|
5
|
-
|
|
6
|
-
describe('bisectionSearchArr', () => {
|
|
7
|
-
it('few cases', () => {
|
|
8
|
-
expect(bisectionSearchArr([1, 2, 3, 4], 1)).toBe(0);
|
|
9
|
-
expect(bisectionSearchArr([1, 2, 3, 4], 2)).toBe(1);
|
|
10
|
-
expect(bisectionSearchArr([1, 2, 3, 4], 3)).toBe(2);
|
|
11
|
-
expect(bisectionSearchArr([1, 2, 3, 4], 4)).toBe(3);
|
|
12
|
-
expect(bisectionSearchArr([1, 2, 3, 4], 0)).toBe(-1);
|
|
13
|
-
expect(bisectionSearchArr([1, 2, 3, 4], 5)).toBe(-1);
|
|
14
|
-
});
|
|
15
|
-
});
|