Gathering detailed insights and metrics for unique-sequences
Gathering detailed insights and metrics for unique-sequences
Gathering detailed insights and metrics for unique-sequences
Gathering detailed insights and metrics for unique-sequences
sequence-runner
Create unique loading text, HTML sequences, and even sprite animations.
@japan-d2/id2
the ID converter that can convert between IDs with different orders and character types and unique numeric sequences.
@kanamone/id2
the ID converter that can convert between IDs with different orders and character types and unique numeric sequences.
seguid
Sequence Globally Unique Identifier (SEGUID) Checksums for Linear, Circular, Single- and Double-Stranded Biological Sequences
npm install unique-sequences
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
Generate short sequences unique within their scope.
This utility is built using Node.js.
1const { generatorCustom } = require('unique-sequences'); 2 3// generate a sequence using elements 'a', 'b' 4const gen = generatorCustom(['a', 'b']); 5console.log(gen.next().value); // a 6console.log(gen.next().value); // b 7console.log(gen.next().value); // ba 8console.log(gen.next().value); // bb
This library generates unique short strings. The generator starts out by creating strings of just one character.
A list of strings are used to generate a sequence of strings similar to the sequence of natural numbers or integers.
For instance, below is a sequence of natural numbers generated using the list of
decimal digits 0
to 9
.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30
Similarly, below is a sequence using the list of latin alphabets a
to j
a, b, c, d, e, f, g, h, i, j,
ba, bb, bc, bd, be, bf, bg, bh, bi, bj,
ca, cb, cc, cd, ce, cf, cg, ch, ci, cj,
da
In a similar manner, this library generates sequences, given a list of strings.
1npm install unique-sequences
1const { 2 generatorCustom, 3 generatorNum, 4 generatorAlphaUpper, 5 generatorAlphaLower, 6 generatorAlphaNumUpper, 7 generatorAlphaNumLower, 8} = require('unique-sequences'); 9 10/* Lets generate a sequence using two elements 'a' and 'b' */ 11const list = ['a', 'b']; 12 13// NOTE: list length must be 2 to 36. 14 15const gen2 = generatorCustom(list); 16console.log(gen2.next().value); // a 17console.log(gen2.next().value); // b 18console.log(gen2.next().value); // ba 19console.log(gen2.next().value); // bb 20console.log(gen2.next().value); // baa 21console.log(gen2.next().value); // bab 22console.log(gen2.next().value); // bba 23console.log(gen2.next().value); // bbb 24console.log(gen2.next().value); // baaa 25 26/* Using three elements 'x', 'y', 'z' */ 27const gen3 = generatorCustom(['x', 'y', 'z']); 28console.log(gen3.next().value); // x 29console.log(gen3.next().value); // y 30console.log(gen3.next().value); // z 31console.log(gen3.next().value); // yx 32console.log(gen3.next().value); // yy 33console.log(gen3.next().value); // yz 34console.log(gen3.next().value); // zx 35console.log(gen3.next().value); // zy 36console.log(gen3.next().value); // zz 37console.log(gen3.next().value); // yxx 38 39/* Let us make a helper to iterate over the sequence generator */ 40function times(gen, count = 64) { 41 const arr = []; 42 for (let i = 0; i < count; i++) { 43 arr.push(gen.next().value); 44 } 45 return arr; 46} 47 48// Generate 10 strings, just like our previous example. 49console.log(times(generatorCustom(['x', 'y', 'z']), 10)); 50// [ 51// 'x', 'y', 'z', 52// 'yx', 'yy', 'yz', 53// 'zx', 'zy', 'zz', 54// 'yxx' 55// ] 56 57/* Lets generate 64 stings using upercase latin alphabets */ 58console.log(times(generatorAlphaUpper())); // 64 is the default 59// [ 60// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 61// 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 62// 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 63// 'Y', 'Z', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 64// 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 65// 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 66// 'BW', 'BX', 'BY', 'BZ', 'CA', 'CB', 'CC', 'CD', 67// 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL' 68// ] 69 70/* There's lower case too */ 71console.log(times(generatorAlphaLower())); 72// [ 73// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 74// 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 75// 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 76// 'y', 'z', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 77// 'bg', 'bh', 'bi', 'bj', 'bk', 'bl', 'bm', 'bn', 78// 'bo', 'bp', 'bq', 'br', 'bs', 'bt', 'bu', 'bv', 79// 'bw', 'bx', 'by', 'bz', 'ca', 'cb', 'cc', 'cd', 80// 'ce', 'cf', 'cg', 'ch', 'ci', 'cj', 'ck', 'cl' 81// ] 82 83/* Alpha Numeric too */ 84console.log(times(generatorAlphaNumLower())); 85// [ 86// '0', '1', '2', '3', '4', '5', '6', '7', 87// '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 88// 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 89// 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 90// 'w', 'x', 'y', 'z', '10', '11', '12', '13', 91// '14', '15', '16', '17', '18', '19', '1a', '1b', 92// '1c', '1d', '1e', '1f', '1g', '1h', '1i', '1j', 93// '1k', '1l', '1m', '1n', '1o', '1p', '1q', '1r' 94// ] 95 96/* Alpha Numeric in upper case */ 97console.log(times(generatorAlphaNumUpper())); 98// [ 99// '0', '1', '2', '3', '4', '5', '6', '7', 100// '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 101// 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 102// 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 103// 'W', 'X', 'Y', 'Z', '10', '11', '12', '13', 104// '14', '15', '16', '17', '18', '19', '1A', '1B', 105// '1C', '1D', '1E', '1F', '1G', '1H', '1I', '1J', 106// '1K', '1L', '1M', '1N', '1O', '1P', '1Q', '1R' 107// ] 108 109/* For the sake of completion, use decimal digits */ 110console.log(times(generatorNum())); 111// [ 112// '0', '1', '2', '3', '4', '5', '6', '7', 113// '8', '9', '10', '11', '12', '13', '14', '15', 114// '16', '17', '18', '19', '20', '21', '22', '23', 115// '24', '25', '26', '27', '28', '29', '30', '31', 116// '32', '33', '34', '35', '36', '37', '38', '39', 117// '40', '41', '42', '43', '44', '45', '46', '47', 118// '48', '49', '50', '51', '52', '53', '54', '55', 119// '56', '57', '58', '59', '60', '61', '62', '63' 120// ] 121 122/* Let's have some fun! */ 123console.log(times(generatorCustom(['rat,', 'a', 'tat']))); 124// [ 125// 'rat,', 'a', 'tat', 126// 'arat,', 'aa', 'atat', 127// 'tatrat,', 'tata', 'tattat', 128// 'arat,rat,', 'arat,a', 'arat,tat', 129// 'aarat,', 'aaa', 'aatat', 130// 'atatrat,', 'atata', 'atattat', 131// 'tatrat,rat,', 'tatrat,a', 'tatrat,tat', 132// 'tatarat,', 'tataa', 'tatatat', 133// 'tattatrat,', 'tattata', 'tattattat', 134// 'arat,rat,rat,', 'arat,rat,a', 'arat,rat,tat', 135// 'arat,arat,', 'arat,aa', 'arat,atat', 136// 'arat,tatrat,', 'arat,tata', 'arat,tattat', 137// 'aarat,rat,', 'aarat,a', 'aarat,tat', 138// 'aaarat,', 'aaaa', 'aaatat', 139// 'aatatrat,', 'aatata', 'aatattat', 140// 'atatrat,rat,', 'atatrat,a', 'atatrat,tat', 141// 'atatarat,', 'atataa', 'atatatat', 142// 'atattatrat,', 'atattata', 'atattattat', 143// 'tatrat,rat,rat,', 'tatrat,rat,a', 'tatrat,rat,tat', 144// 'tatrat,arat,', 'tatrat,aa', 'tatrat,atat', 145// 'tatrat,tatrat,', 'tatrat,tata', 'tatrat,tattat', 146// 'tatarat,rat,' 147// ] 148 149/* Lower case alphabets again, but this time specify the characters. */ 150console.log(times(generatorCustom([ 151 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 152 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 153 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 154 'y', 'z', 155]))); 156 157// [ 158// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 159// 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 160// 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 161// 'y', 'z', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 162// 'bg', 'bh', 'bi', 'bj', 'bk', 'bl', 'bm', 'bn', 163// 'bo', 'bp', 'bq', 'br', 'bs', 'bt', 'bu', 'bv', 164// 'bw', 'bx', 'by', 'bz', 'ca', 'cb', 'cc', 'cd', 165// 'ce', 'cf', 'cg', 'ch', 'ci', 'cj', 'ck', 'cl' 166// ] 167 168/* Lastly, lets give a shot at using using upper and lower cases */ 169try { 170console.log(times(generatorCustom([ 171 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 172 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 173 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 174 'y', 'z', 175 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 176 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 177 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 178 'Y', 'Z', 179]))); 180} catch (e) { 181 console.error('error:', e.message); 182} 183// error: maximum list length is 36, got 52. 184 185// Thats because length must be 2 to 36.
2021-12-16
Note: Change log dates are yyyy-mm-dd.
No vulnerabilities found.
No security vulnerabilities found.