Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sequential-ids

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequential-ids - npm Package Compare versions

Comparing version 0.0.0-alpha.1.0 to 0.0.0-alpha.2.0

2

package.json
{
"name": "sequential-ids",
"version": "0.0.0-alpha.1.0",
"version": "0.0.0-alpha.2.0",
"description": "centralized generation of sequential, human-readable ids",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/GochoMugo/sequential-ids",

@@ -12,5 +12,5 @@

|-------|-----:|
|version|0.0.0-alpha.1.0|
|version|0.0.0-alpha.2.0|
|dependencies|none|
|last update|2nd Sept, 2014|
|last updated|4th Sept, 2014|

@@ -29,16 +29,26 @@

// assuming `db` is a variable holding a database object
// with the method `.store(key, value)`
// and `.read(key)`
var sequential = require("sequential-ids");
var generator = new sequential.Generator({
digits: 6,
letters: 3,
store: function (id) {
// assuming `db` is a variable holding a database object
// with the method `.store(value)`
db.store(id)
}
store: function (ids) {
db.store("last-id", ids[ids.length - 1]);
},
restore: (function () {
return db.read("last-id");
})()
});
var accessor = new sequential.Accessor()
var id_x = accessor.next()
var id_y = accessor.next()
accessor.next(function (id) {
console.log("First ID: " + id);
});
accessor.next(function (id) {
console.log("Second ID: " + id);
});

@@ -53,3 +63,3 @@ ```

* you only require to create a single generator instance
* options object have:
* **options** is an object having the following attributes:

@@ -67,2 +77,4 @@ * `digits`:

* a function that will be called to store the IDs on disk for persistence.
* the function is passed an array of IDs that have been generated.
* repeatedly storing the last id is useful to know where to start from in the next session.
* Defaults to `null`.

@@ -78,2 +90,3 @@ * `store_freq`:

* If not specified, generates from start.
* **MUST** be a string, or a function called that **returns** a string as in example above.
* Defaults to `null`.

@@ -98,3 +111,3 @@ * `port`:

* used to access ids.
* `port` is the port number of your generator. In case where, you did not specify a port when creating a Generator instance, you may leave this out. Defaults to `9876`.
* **port** is the port number of your generator. In case where, you did not specify a port when creating a Generator instance, you may leave this out. Defaults to `9876`.
* an accessor has the following methods:

@@ -128,1 +141,2 @@

[npmjs]:https://npmjs.org/sequential-ids
[mit]:https://opensource.org/licenses/MIT

@@ -18,2 +18,6 @@

function Generator(options) {
var hyphenIndex, letters, lettersFound, numbers, numbersFound;
if (options == null) {
options = {};
}
this.used = __bind(this.used, this);

@@ -24,3 +28,2 @@ this.toString = __bind(this.toString, this);

this.incrementNumber = __bind(this.incrementNumber, this);
var hyphenIndex, letters, lettersFound, numbers, numbersFound;
this.options = {

@@ -27,0 +30,0 @@ digits: options.digits != null ? options.digits : 6,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc