unique-sequence
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "unique-sequence", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Generate a sequence of short strings unique within their scope.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,8 +5,35 @@ # unique-sequence | ||
The generated strings are **as short as possible**. | ||
Unlike `uuid` they are not universally unique. However a generator does not | ||
repeat a sequence, making strings unique within the scope of a generator | ||
instance. | ||
This utility is built using [Node.js](https://nodejs.org/en/about/). | ||
# Introduction | ||
This library was written to generate **short** property names for `JavaScript` objects. | ||
`uuid` is one way of generating property names which would make an object look like: | ||
```js | ||
{ | ||
'2bdff0e2-9c4f-4b12-8669-7dac3dbf3203': 1, | ||
'7b5c615c-03b2-4bb0-b8ff-995cebeed679': true | ||
} | ||
``` | ||
In the above, property names `2bdff0e2-9c4f-4b12-8669-7dac3dbf3203`, | ||
`7b5c615c-03b2-4bb0-b8ff-995cebeed679` are relatively long. | ||
Instead, if you want to generate a **few** and **very short** names such as `a`, | ||
`b` then this library can help. | ||
# Quick example | ||
```js | ||
const { generatorCustom } = require('unique-sequence'); | ||
// generate a sequence using elements 'a', 'b' | ||
// A string generator using 2 characters: 'a' and 'b': | ||
const gen = generatorCustom(['a', 'b']); | ||
@@ -17,24 +44,13 @@ console.log(gen.next().value); // a | ||
console.log(gen.next().value); // bb | ||
console.log(gen.next().value); // baa | ||
// and so on... | ||
``` | ||
# Generators available | ||
# How it works | ||
1. generatorCustom | ||
2. generatorAlphaUpper | ||
3. generatorAlphaLower | ||
4. generatorAlphaNumUpper | ||
5. generatorAlphaNumLower | ||
6. generatorNum | ||
It is similar to a sequence of integers. | ||
# Introduction | ||
For instance, below is a sequence generated using decimal digits `0` to `9`: | ||
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`. | ||
``` | ||
@@ -47,3 +63,3 @@ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | ||
Similarly, below is a sequence using the list of latin alphabets `a` to `j` | ||
Below is a sequence using the list of latin alphabets `a` to `j`: | ||
@@ -57,4 +73,14 @@ ``` | ||
In a similar manner, this library generates sequences, given a list of strings. | ||
In a similar manner, this library generates sequences, using a specified list of | ||
characters (or strings). | ||
# Generators available | ||
1. generatorCustom | ||
2. generatorAlphaUpper | ||
3. generatorAlphaLower | ||
4. generatorAlphaNumUpper | ||
5. generatorAlphaNumLower | ||
6. generatorNum | ||
# Getting started | ||
@@ -83,3 +109,3 @@ | ||
// NOTE: list length must be 2 to 36. | ||
// NOTE: The length of the list should be <=36 and >= 2 | ||
@@ -262,2 +288,8 @@ const gen2 = generatorCustom(list); | ||
## version 1.0.3 | ||
2022-01-15 | ||
+ Improved docs. | ||
## version 1.0.0 | ||
@@ -264,0 +296,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67494
297
10430