bb26 3.0.0 → 3.0.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/package.json +1 -1
- package/readme.md +40 -38
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# BB26
|
|
2
2
|
|
|
3
|
-
[](https://bundlephobia.com/result?p=bb26)
|
|
4
3
|
[](https://www.npmjs.com/package/bb26)
|
|
5
4
|
[](https://codeclimate.com/github/patrik-csak/BB26/test_coverage)
|
|
6
5
|
|
|
@@ -19,6 +18,9 @@ Decimal: | 1 | 2 | 3 | ... | 24 | 25 | 26 | 27 | 28 | 29 | ...
|
|
|
19
18
|
|
|
20
19
|
## Install
|
|
21
20
|
|
|
21
|
+
> **Note**
|
|
22
|
+
> This package is a native ECMAScript Module (ESM). If your project is not ESM, read [Sindre Sorhus’s Pure ESM package article](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
|
|
23
|
+
|
|
22
24
|
```sh
|
|
23
25
|
npm install bb26
|
|
24
26
|
```
|
|
@@ -27,87 +29,87 @@ npm install bb26
|
|
|
27
29
|
|
|
28
30
|
### `increment()`
|
|
29
31
|
|
|
30
|
-
```
|
|
31
|
-
increment(string: string): string
|
|
32
|
+
```ts
|
|
33
|
+
function increment(string: string): string;
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
Increments a bijective base-26 string by one numeral.
|
|
35
37
|
|
|
36
38
|
```js
|
|
37
|
-
import { increment } from
|
|
39
|
+
import { increment } from "bb26";
|
|
38
40
|
|
|
39
|
-
increment(
|
|
40
|
-
increment(
|
|
41
|
-
increment(
|
|
41
|
+
increment("A"); // 'B'
|
|
42
|
+
increment("Z"); // 'AA'
|
|
43
|
+
increment("AA"); // 'AB'
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
### `random()`
|
|
45
47
|
|
|
46
|
-
```
|
|
47
|
-
random(upper: string): string
|
|
48
|
-
random(lower: string, upper: string): string
|
|
48
|
+
```ts
|
|
49
|
+
function random(upper: string): string
|
|
50
|
+
function random(lower: string, upper: string): string
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
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.
|
|
52
54
|
|
|
53
55
|
```js
|
|
54
|
-
import { random } from
|
|
56
|
+
import { random } from "bb26";
|
|
55
57
|
|
|
56
|
-
random(
|
|
57
|
-
random(
|
|
58
|
+
random("AAA"); // 'NE'
|
|
59
|
+
random("AAA", "AAAA"); // 'KXZ'
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
### `range()`
|
|
61
63
|
|
|
62
|
-
```
|
|
63
|
-
range(end: string): string[]
|
|
64
|
-
range(start: string, end: string): string[]
|
|
64
|
+
```ts
|
|
65
|
+
function range(end: string): string[]
|
|
66
|
+
function range(start: string, end: string): string[]
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
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'`.
|
|
68
70
|
|
|
69
71
|
```js
|
|
70
|
-
import { range } from
|
|
72
|
+
import { range } from "bb26";
|
|
71
73
|
|
|
72
|
-
range(
|
|
73
|
-
range(
|
|
74
|
-
range(
|
|
75
|
-
range(
|
|
76
|
-
range(
|
|
74
|
+
range("B"); // ['A']
|
|
75
|
+
range("C"); // ['A', 'B']
|
|
76
|
+
range("B", "C"); // ['B']
|
|
77
|
+
range("B", "D"); // ['B', 'C']
|
|
78
|
+
range("Z", "AC"); // ['Z', 'AA', 'AB']
|
|
77
79
|
```
|
|
78
80
|
|
|
79
81
|
### `toBb26()`
|
|
80
82
|
|
|
81
|
-
```
|
|
82
|
-
toBb26(number: number): string
|
|
83
|
+
```ts
|
|
84
|
+
function toBb26(number: number): string;
|
|
83
85
|
```
|
|
84
86
|
|
|
85
87
|
Converts a decimal number to a bijective base-26 string.
|
|
86
88
|
|
|
87
89
|
```js
|
|
88
|
-
import { toBb26 } from
|
|
90
|
+
import { toBb26 } from "bb26";
|
|
89
91
|
|
|
90
|
-
toBb26(1) // 'A'
|
|
91
|
-
toBb26(2) // 'B'
|
|
92
|
-
toBb26(26) // 'Z'
|
|
93
|
-
toBb26(27) // 'AA'
|
|
94
|
-
toBb26(28) // 'AB'
|
|
92
|
+
toBb26(1); // 'A'
|
|
93
|
+
toBb26(2); // 'B'
|
|
94
|
+
toBb26(26); // 'Z'
|
|
95
|
+
toBb26(27); // 'AA'
|
|
96
|
+
toBb26(28); // 'AB'
|
|
95
97
|
```
|
|
96
98
|
|
|
97
99
|
### `toDecimal()`
|
|
98
100
|
|
|
99
|
-
```
|
|
100
|
-
toDecimal(string: string): number
|
|
101
|
+
```ts
|
|
102
|
+
function toDecimal(string: string): number;
|
|
101
103
|
```
|
|
102
104
|
|
|
103
105
|
Converts a bijective base-26 string to a decimal number.
|
|
104
106
|
|
|
105
107
|
```js
|
|
106
|
-
import { toDecimal } from
|
|
108
|
+
import { toDecimal } from "bb26";
|
|
107
109
|
|
|
108
|
-
toDecimal(
|
|
109
|
-
toDecimal(
|
|
110
|
-
toDecimal(
|
|
111
|
-
toDecimal(
|
|
112
|
-
toDecimal(
|
|
110
|
+
toDecimal("A"); // 1
|
|
111
|
+
toDecimal("B"); // 2
|
|
112
|
+
toDecimal("Z"); // 26
|
|
113
|
+
toDecimal("AA"); // 27
|
|
114
|
+
toDecimal("AB"); // 28
|
|
113
115
|
```
|