bb26 2.1.1 → 2.2.1
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/increment.js +6 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -7
- package/dist/random.d.ts +2 -3
- package/dist/random.js +9 -5
- package/dist/range.d.ts +2 -3
- package/dist/range.js +12 -8
- package/dist/to-bb26.js +2 -2
- package/dist/to-decimal.js +3 -3
- package/license.txt +1 -1
- package/package.json +27 -22
- package/readme.md +15 -6
- package/dist/sample.d.ts +0 -1
- package/dist/sample.js +0 -6
package/dist/increment.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
const to_bb26_1 = __importDefault(require("./to-bb26"));
|
|
7
|
+
const to_decimal_1 = __importDefault(require("./to-decimal"));
|
|
5
8
|
/**
|
|
6
9
|
* Increments a bijective base-26 string by one numeral.
|
|
7
10
|
*
|
|
@@ -17,6 +20,6 @@ var to_decimal_1 = require("./to-decimal");
|
|
|
17
20
|
* @return Incremented string
|
|
18
21
|
*/
|
|
19
22
|
function increment(string) {
|
|
20
|
-
return to_bb26_1.default(to_decimal_1.default(string) + 1);
|
|
23
|
+
return (0, to_bb26_1.default)((0, to_decimal_1.default)(string) + 1);
|
|
21
24
|
}
|
|
22
25
|
exports.default = increment;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import increment from './increment';
|
|
2
2
|
import random from './random';
|
|
3
3
|
import range from './range';
|
|
4
|
-
import toDecimal from './to-decimal';
|
|
5
4
|
import toBb26 from './to-bb26';
|
|
6
|
-
|
|
5
|
+
import toDecimal from './to-decimal';
|
|
6
|
+
export { increment, random, range, toBb26, toDecimal };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
6
|
+
exports.toDecimal = exports.toBb26 = exports.range = exports.random = exports.increment = void 0;
|
|
7
|
+
const increment_1 = __importDefault(require("./increment"));
|
|
5
8
|
exports.increment = increment_1.default;
|
|
6
|
-
|
|
9
|
+
const random_1 = __importDefault(require("./random"));
|
|
7
10
|
exports.random = random_1.default;
|
|
8
|
-
|
|
11
|
+
const range_1 = __importDefault(require("./range"));
|
|
9
12
|
exports.range = range_1.default;
|
|
10
|
-
|
|
11
|
-
exports.toDecimal = to_decimal_1.default;
|
|
12
|
-
var to_bb26_1 = require("./to-bb26");
|
|
13
|
+
const to_bb26_1 = __importDefault(require("./to-bb26"));
|
|
13
14
|
exports.toBb26 = to_bb26_1.default;
|
|
15
|
+
const to_decimal_1 = __importDefault(require("./to-decimal"));
|
|
16
|
+
exports.toDecimal = to_decimal_1.default;
|
package/dist/random.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default random;
|
|
1
|
+
export default function random(upper: string): string;
|
|
2
|
+
export default function random(lower: string, upper: string): string;
|
package/dist/random.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/unified-signatures, no-redeclare */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
const random_item_1 = __importDefault(require("random-item"));
|
|
8
|
+
const range_1 = __importDefault(require("./range"));
|
|
5
9
|
/**
|
|
6
10
|
* Produces a random string between the inclusive `lower` and `upper` bounds. If
|
|
7
11
|
* only one argument is provided, a string between `'A'` and the given string is
|
|
@@ -19,8 +23,8 @@ var sample_1 = require("./sample");
|
|
|
19
23
|
* @returns Random string
|
|
20
24
|
*/
|
|
21
25
|
function random(lower, upper) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
26
|
+
const start = upper ? lower : 'A';
|
|
27
|
+
const end = upper !== null && upper !== void 0 ? upper : lower;
|
|
28
|
+
return (0, random_item_1.default)((0, range_1.default)(start, end));
|
|
25
29
|
}
|
|
26
30
|
exports.default = random;
|
package/dist/range.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default range;
|
|
1
|
+
export default function range(end: string): string[];
|
|
2
|
+
export default function range(start: string, end: string): string[];
|
package/dist/range.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/unified-signatures, no-redeclare */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
const to_decimal_1 = __importDefault(require("./to-decimal"));
|
|
8
|
+
const increment_1 = __importDefault(require("./increment"));
|
|
5
9
|
/**
|
|
6
10
|
* Creates an array of bijective base-26 numerals progressing from `start` up
|
|
7
11
|
* to, but not including, `end`.
|
|
@@ -22,12 +26,12 @@ var increment_1 = require("./increment");
|
|
|
22
26
|
* @param end - The end of the range
|
|
23
27
|
*/
|
|
24
28
|
function range(start, end) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
for (
|
|
29
|
-
|
|
29
|
+
const _range = [];
|
|
30
|
+
const _end = end !== null && end !== void 0 ? end : start;
|
|
31
|
+
const _start = end ? start : 'A';
|
|
32
|
+
for (let i = _start; (0, to_decimal_1.default)(i) < (0, to_decimal_1.default)(_end); i = (0, increment_1.default)(i)) {
|
|
33
|
+
_range.push(i);
|
|
30
34
|
}
|
|
31
|
-
return
|
|
35
|
+
return _range;
|
|
32
36
|
}
|
|
33
37
|
exports.default = range;
|
package/dist/to-bb26.js
CHANGED
|
@@ -19,8 +19,8 @@ function toChar(number) {
|
|
|
19
19
|
* @param number
|
|
20
20
|
*/
|
|
21
21
|
function toBb26(number) {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
let string = '';
|
|
23
|
+
let _number = number;
|
|
24
24
|
while (_number > 0) {
|
|
25
25
|
string = toChar(_number % 26 || 26) + string;
|
|
26
26
|
_number = Math.floor((_number - 1) / 26);
|
package/dist/to-decimal.js
CHANGED
|
@@ -22,9 +22,9 @@ function toDecimal(string) {
|
|
|
22
22
|
if (!/[A-Z]/.test(string)) {
|
|
23
23
|
throw new Error('String must contain only upper-case characters');
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
for (
|
|
27
|
-
|
|
25
|
+
let number = 0;
|
|
26
|
+
for (let i = 0; i < string.length; i++) {
|
|
27
|
+
const char = string[string.length - i - 1];
|
|
28
28
|
number += Math.pow(26, i) * charToDecimal(char);
|
|
29
29
|
}
|
|
30
30
|
return number;
|
package/license.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bb26",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
5
|
-
"repository": "github:ptrkcsk/BB26",
|
|
6
|
-
"author": "Patrik Csak <p@trikcsak.com>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"bugs": {
|
|
9
|
-
"url": "https://github.com/ptrkcsk/BB26/issues"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/ptrkcsk/BB26#readme",
|
|
3
|
+
"version": "2.2.1",
|
|
4
|
+
"description": "Utilities for working with bijective base-26 numerals",
|
|
12
5
|
"keywords": [
|
|
13
6
|
"base 26",
|
|
14
7
|
"bijective base 26",
|
|
15
8
|
"hexavigesimal",
|
|
16
9
|
"spreadsheet",
|
|
17
10
|
"spreadsheet column",
|
|
18
|
-
"spreadsheet column letters"
|
|
11
|
+
"spreadsheet column letters",
|
|
12
|
+
"license plate serials"
|
|
19
13
|
],
|
|
20
|
-
"
|
|
14
|
+
"homepage": "https://github.com/ptrkcsk/BB26#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/ptrkcsk/BB26/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Patrik Csak <p@trikcsak.com>",
|
|
21
20
|
"files": [
|
|
22
21
|
"dist"
|
|
23
22
|
],
|
|
23
|
+
"main": "dist",
|
|
24
|
+
"repository": "github:ptrkcsk/BB26",
|
|
24
25
|
"scripts": {
|
|
25
26
|
"build": "tsc",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"test": "
|
|
29
|
-
"test:coverage": "
|
|
27
|
+
"format": "xo --fix",
|
|
28
|
+
"prepare": "del-cli dist && npm run build",
|
|
29
|
+
"test": "xo && ava",
|
|
30
|
+
"test:coverage": "del-cli coverage && xo && c8 ava",
|
|
31
|
+
"test:coverage:lcov": "del-cli coverage && xo && c8 --reporter=lcovonly ava"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"random-item": "^3.1.0"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
38
|
+
"ava": "^3.15.0",
|
|
39
|
+
"c8": "^7.10.0",
|
|
40
|
+
"del-cli": "^4.0.1",
|
|
41
|
+
"ts-node": "^10.4.0",
|
|
42
|
+
"typescript": "^4.0.5",
|
|
43
|
+
"xo": "^0.39.1"
|
|
39
44
|
},
|
|
40
45
|
"types": "dist"
|
|
41
46
|
}
|
package/readme.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
# BB26
|
|
2
2
|
|
|
3
|
-
[](https://bundlephobia.com/result?p=bb26) [](https://www.npmjs.com/package/bb26) [](https://codeclimate.com/github/ptrkcsk/BB26/test_coverage)
|
|
4
4
|
|
|
5
|
-
JavaScript [bijective base-26](https://en.wikipedia.org/wiki/Bijective_numeration#The_bijective_base-26_system)
|
|
5
|
+
BB26 is a JavaScript library for working with [bijective base-26](https://en.wikipedia.org/wiki/Bijective_numeration#The_bijective_base-26_system) (BB26) numbers
|
|
6
|
+
|
|
7
|
+
## What is bijective base-26 numeration?
|
|
8
|
+
|
|
9
|
+
You're probably familiar with BB26 numeration. It's used for spreadsheet columns, license plate serials, and (probably?) more.
|
|
10
|
+
|
|
11
|
+
Here's an example of decimal (base-10) numbers (the numbers you use every day to count things) compared to their corresponding BB26 numbers:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Decimal: | 1 | 2 | 3 | ... | 24 | 25 | 26 | 27 | 28 | 29 | ...
|
|
15
|
+
BB26: | A | B | C | ... | X | Y | Z | AA | AB | AC | ...
|
|
16
|
+
```
|
|
6
17
|
|
|
7
18
|
## Installation
|
|
8
19
|
|
|
@@ -35,7 +46,7 @@ random(upper: string): string
|
|
|
35
46
|
random(lower: string, upper: string): string
|
|
36
47
|
```
|
|
37
48
|
|
|
38
|
-
Produces a random string between the inclusive lower and upper bounds. If only one argument is provided, a string between 'A' and the given string is returned.
|
|
49
|
+
Produces a random string between the inclusive `lower` and `upper` bounds. If only one argument is provided, a string between `'A'` and the given string is returned.
|
|
39
50
|
|
|
40
51
|
```js
|
|
41
52
|
import { random } from 'bb26'
|
|
@@ -51,9 +62,7 @@ range(end: string): string[]
|
|
|
51
62
|
range(start: string, end: string): string[]
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
Creates an array of bijective base-26 numerals progressing from start up to, but not including, end
|
|
55
|
-
|
|
56
|
-
If end is not specified, it's set to start with start then set to 'A'.
|
|
65
|
+
Creates an array of bijective base-26 numerals progressing from `start` up to, but not including, `end`. If `end` is not specified, it's set to `start` with `start` then set to `'A'`.
|
|
57
66
|
|
|
58
67
|
```js
|
|
59
68
|
import { range } from 'bb26'
|
package/dist/sample.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function sample<T>(array: T[]): T;
|